I have two interfaces defined in C#, as below:
[Guid("4938540B-3DB2-452c-A061-59EC499657E7")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IRADevice
{
Void FA();
}
/// <summary>
/// IRADevice interface represents a given RADevice.
/// </summary>
[Guid("4938540B-3DB2-452c-A061-59EC499657E8")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IRADevice2 : IRADevice
{
void FB();
}
In c++ code, I import the tlb produced by above interface using following command
#import "device.tlb" raw_interfaces_only
The created tlh file is as below:
struct __declspec(uuid("4938540b-3db2-452c-a061-59ec499657e7"))
IRADevice : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall FA ( ) = 0;
};
struct __declspec(uuid("4938540b-3db2-452c-a061-59ec499657e8"))
IRADevice2 : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall FB ( ) = 0;
};
I expect IRADevice derives from IRADevice not from IDispatch, and includes FA function. Can anybody tell me where I did wrong?
As @HansPassant stated this is a known limitation. It took me a minute but I found some relevant documentation to support that fact. http://msdn.microsoft.com/en-us/library/aa645736(v=vs.71).aspx
The most relevant portion being:
COM interfaces declared in C# must include declarations for all members of their base interfaces with the exception of members of IUnknown and IDispatch — the .NET Framework automatically adds these. COM interfaces which derive from IDispatch must be marked with the InterfaceType attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With