Question

I'm experimenting with hosting CLR (not trying to use mono for now, though I will probably try). Basically, I'm following this:

http://www.lenholgate.com/blog/2010/07/clr-hosting---a-flexible-managed-plugin-system-part-1.html

However, I've got some troubles with COM itself, as it's not so thoroughly explained in that article, and I'm learning as I go (haven't been playing with COM before).

I've defined an interface:

import "unknwn.idl";
[
    object,
    uuid(55d96f88-9633-4ad7-b9de-1a546ea73307),
    helpstring("INative interface"),
    pointer_default(unique)
]
interface INative : IUnknown
{
    HRESULT Write(BSTR s);
}
[
   object,
   uuid(74eeeaaa-d73c-436e-b52d-5c8a972ce60a),
   helpstring("ITestManager Interface"),
   pointer_default(unique)
]
interface IManagedHost : IUnknown
{
    HRESULT Init(INative* native);
}

And included generated files in my native project. However, I can't build the executable, because linker cannot resolve: _CStdStubBuffer_Release@4. The RpcRT4.lib is linked, but I've run dumpbin rpcrt4.lib /all | grep _CStdStubBuffer_Release and there is nothing like that exported by that library, there is CStdStubBuffer_DebugServerRelease. So, question is what exactly references that method, if it supposedly should not exist?

Did some more investigation, and I've found out that this method is referenced via the .c file that is generated by IDL tool:

const CInterfaceStubVtbl _INativeStubVtbl =
{
    &IID_INative,
    &INative_ServerInfo,
    4,
    0, /* pure interpreted */
    CStdStubBuffer_METHODS
};

and CStdStubBuffer_METHODS are defined in RpcProxy.h of windows SDK v7.0A:

#define CStdStubBuffer_METHODS \
    CStdStubBuffer_QueryInterface,\
    CStdStubBuffer_AddRef, \
    CStdStubBuffer_Release, \
    CStdStubBuffer_Connect, \
    CStdStubBuffer_Disconnect, \
    CStdStubBuffer_Invoke, \
    CStdStubBuffer_IsIIDSupported, \
    CStdStubBuffer_CountRefs, \
    CStdStubBuffer_DebugServerQueryInterface, \
    CStdStubBuffer_DebugServerRelease

which indeed wants that CStdStubBuffer_Release method, though it's a bit different than: http://msdn.microsoft.com/en-us/library/windows/desktop/ms764247%28v=VS.85%29.aspx.

What other library should I link then?

Was it helpful?

Solution

CStdStubBuffer_Release() is implemented by another file that's auto-generated by midl.exe, dlldata.c. The DLLDATA_ROUTINES macro generates it.

This problem is pointing to a project configuration mistake, sounds like you added the proxy .c file to your main project instead of using it in the proxy/stub project. Which also consumes the dlldata.c. I'm pretty sure there is no need for the proxy/stub in a custom CLR host, so simply remove the .c file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top