views:

57

answers:

3

I have a C# implementation of a C++ COM Interface. I have ported the IDL (Interface) as accurately as I can.

When the C++ app instantiates my object it successfully calls one of the methods. It then tries to call another of the methods but nothing happens. The second call's execution path never makes it to the C# side.

I don't have access to the C++ exe code. I do have a working compiled C++ version of the COM DLL object with code. This is what I am trying to replace in C#.

What can I use to compare the interfaces of the C++ COM and C# COM DLLs to see if there are any differences? Is this even possible? I've tried OLE View by microsoft, but it failes to open the C++ DLL. I think if I can see that my DLL looks exactly like the C++ one it might work.

This question is more about helping my understand where I can go from here. I have asked a very detailed question about the exact implementation I am trying to acheive, but no one is interested. This is why I'm posting a more general question to help guide me to the answer.

I'm really stuck. 25+ hours gone on this already heh.

A: 

Have you marked the C# interface with the InterfaceTypeAttribute to tell the CLR that it should marshal it either as IUnknown or as IDispatch?

Because if you didn't, your method slots in the VMT will be messed up.

Robert Giesecke
Yes, it is IUnknown as per the IDL
Nanook
A: 

I don't suppose you could write your own test app (C++ or C# or both) to work your C# implementation and see what's happening? Feel free to ignore if you've done that already.

A: 

After solving my compatibility issue, I discovered that The C++ dll doesn't expose the interface items I was expecting. Although this question was aimed at how to debug or compare the exposed interfaces of the 2 dlls, I got my project working by using the [ComImport] attribute on the C# interfaces I was implementing rather than [ComVisible(true)]. I used the [PreserveSig] attribute on the interface declarations to enforce compatibility. This is my understanding of what is happening.

Nanook