Hi all,
I have a custom dll which returns a class pointer from its exported function. The calling in C# is similar to this:
public interface IUnknown
{
unsafe ulong QueryInterface(ref Guid riid, out IntPtr ppv);
ulong AddRef();
ulong Release();
};
public interface IClass : IUnknown
{
bool GetVersion(ref VERSION_INFO version);
}
#region a.dll imports
[DllImport("a.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
public static extern IClass GetIClass();
#endregion
That exported function in C is like this:
__declspec(dllexport) IClass* __stdcall GetIClass(void)
The calling in C#:
IClass class;
class = GetIClass();
But the debugger tells me there is no this interface in the dll.
If I change the C# definition to:
public static extern IntPtr GetIClass();
the call succeeds but I cannot change IntPtr to IClass due to the compiler errors.
So, could anybody here help me with this I'm really new to C# - just couple days experience.
Thanks a lot.
Cheers~~