C # interface cannot work properly in C ++

I have two interfaces defined in C # as shown 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 created by the above interface using the following command

#import "device.tlb"  raw_interfaces_only

The generated tlh file looks like this:

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 that IRADevice comes from IRADevice, not from IDispatch, and includes the FA function. Can someone tell me where I was wrong?

+5
source share
1 answer

As @HansPassant said, this is a known limitation. It took me a minute, but I found the relevant documentation confirming this fact. http://msdn.microsoft.com/en-us/library/aa645736(v=vs.71).aspx

The most important part:

COM-, #, , IUnknown IDispatch -.NET Framework . COM-, IDispatch, InterfaceType.

+2

All Articles