Discussion:
marshalling tagVariant from C# to C++
(too old to reply)
Jediah L.
2009-12-16 13:33:56 UTC
Permalink
I am trying to call through an interop from C#. The last parameter is
marshalled as an object; but it's underlying type of tagVariant. I have
tried numerous ways to pass this value in from C#, something as complex as
creating a struct that mimics the tagVarariant type in C++ and things as
simple as creating an object array populating it with a ushort and long (to
represent the VT and lVal that I'm passing in).

When I pass the object array I get an exception of specified type is not
valid; when I pass the struct, I get an error stating the value was not in
the expected range.

I'm also aware of of functions called
GetObjectForNativeVariant/GetNativeVariantForObject as part of
the .Net Framework; however, I'm not sure where I would get the Native
Variant reference to pass in to this function to get a reference to the
struct tagVariant defined in OAIDL.h....


Jediah L.
Jialiang Ge [MSFT]
2009-12-17 06:21:30 UTC
Permalink
Hello Jediah

Are you referrring to tagVARIANT instead of tagVariant?
http://msdn.microsoft.com/en-us/library/ms221627.aspx

As far as I know, you do not need to manually manipulate the tagVARIANT (or
VARIANT) struct on the .NET side. It's automatically marshalled as object
for you. Could you please let me know the prototype of the native function,
and share some sample code to show what you are trying to do? I will help
to dig into it.

Regards,
Jialiang Ge (***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Jialiang Ge [MSFT]
2009-12-21 10:35:04 UTC
Permalink
Hello

If it's convenient, could you please give me the prototype of the native
function that is failing as I requested in the last reply? It is important
for me to know the native prototype to dig into the problem.

pCertView.SetRestriction(pCertView.GetColumnIndex((int)fResultColumn.CVRC_CO
LUMN_SCHEMA,
"Request.StatusCode"),
(int)SEEKOPERATOR.CVR_SEEK_GT, (int)SORTORDER.CVR_SORT_ASC,
ref
statusIDRestriction);


Regards,
Jialiang Ge (***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
***@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

Loading...