I am using COM interop to call a method in a C# dll from a C++ dll. The C++ dll is called from another application that is essentially a black box to me (e.g. I can't see any of it's code.)
When this application calls the method in the C++ dll, it executes as expected until trying to create the pointer/allocate memory to the C# COM interface, at which point the method fails (error is logged):
TJIntegration::ITJInterfacePtr tJPtr = NULL;
HRESULT hRes = tJPtr.CreateInstance(__uuidof(TJIntegration::TJInterface));
if (!(SUCCEEDED(hRes)))
{
LOG_ERROR << "Could not create pointer for TJInterface. Has the COM DLL been registered?";
}
However, I have created a test application that also calls into this dll, and the method executes completely as expected, including creating this pointer.
I am testing these applications on the same machine (where the dll is registered) so I can't understand why the method would function correctly when called from one application, but fail at this point when called from another?
It turns out that I needed to use the /codebase
option when using regasm to register the dll.