Can You Pass A COM Interface Instantiated In C# Back To C++?

Viewed 54

I have a C++ COM EXE that does processing. I want to allow UI EXEs (including C# ones) to "register" with it, so that when it finishes processing it will pass the result to any of the UIs that have registered. I've declared a COM interface in C++:

interface ICoreToUI : IDispatch
{
    HRESULT OnFlaw([in] IFlawData *pFlawData);
};

In my C# program I have a class which inherits from the above

public class CoreToUI : ICoreToUI
{
    public void OnFlaw(IFlawData flaw)
    {
        //TODO
    }
}

The EXE has the following function:

STDMETHOD(AddUI)(ICoreToUI *pUI);

I was hoping to do the following from the C# project (IWICore is the COM interface for the core):

IWICore iWICore = new WICore();
ICoreToUI coreToUI = new CoreToUI();
iWICore.AddUI(coreToUI);  **<= FAILS!**

But the AddUI() call throws a COMException 'Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY).

Is there a way to do what I'd like?

0 Answers
Related