"Michael" <michael.jaskiewicz@gdc4s.com> wrote in message
news:5fab30dd-9a42-4d05-a85e-0cd556ae4f88@developmentnow.com...
> Hi, I've been banging my head against this one and now I'm about to
> scream. Any suggestions appreciated. I've scoured the net too and for some
> reason all suggestions don't work.
>
> I've got a C++ app that takes a function pointer from a C# application
> (it's for a callback). The callback signature looks like this.
> void callbackSignature( SpecialType *st );
>
> The SpecialType is a struct that looks like the following (in C++).
> struct SpecialType{
> VARIANT a;
> VARIANT b;
> }
>
> Now, what I'm trying to do is fire the callback from C++ and catch it and
> process the SpecialType in C#.
>
> I've implemented a struct in my C# application that mirrors the C++ one
> that looks like
> public struct SpecialCSharpType{
> Object a;
> Object b;
> }
>
> The actual callback in C# that gets implemented has a signature that looks
> like the following.
> static void CSharpCallback( IntPtr special );
> When I get the special type, I know that it's an instance of my
> SpecialType, so I marshal it over using Marshal.PtrToStructure.
> SpecialCSharpType scs = Marshal.PtrToStructure( special, typeof(
> SpecialCSharpType ) );
>
> The funny thing is that when the previous line executes, the application
> just totally crashes. I can wrap it in exception handling but to no avail.
> My question is, does the marshalling of a struct that contains VARIANTs
> require some sort of special handling?
> Any help is appreciated. Thanks,
> mj
>
> From
>
http://www.developmentnow.com/g/21_2003_9_8_0_0/dotnet-framework-interop.htm >
> Posted via DevelopmentNow.com Groups
>
http://www.developmentnow.com