I have this code in C++/CLI project:
CSafePtr<IEngine> engine;
HMODULE libraryHandle;
libraryHandle = LoadLibraryEx("FREngine.dll", 0, LOAD_WITH_ALTERED_SEARCH_PATH);
typedef HRESULT (STDAPICALLTYPE* GetEngineObjectFunc)(BSTR, BSTR, BSTR, IEngine**);
GetEngineObjectFunc pGetEngineObject = (GetEngineObjectFunc)GetProcAddress(libraryHandle, "GetEngineObject");
pGetEngineObject( freDeveloperSN, 0, 0, &engine )
last line throws this exception:
RPC Server in not available
What may causing this exception?
ABBYY FRE is a COM object.
GetEngineObject()
behaves like a normal COM interface method except it's a separate function. Which means the following: it doesn't allow exceptions propagate outside. To achieve this it catches all exceptions, translates them into appropriateHRESULT
values and possibly sets upIErrorInfo
.You trying to analyze the exception thrown inside a method have no chances to find what the problem is. That's because internally it might work like this:
so the actual call can catch exceptions and translate them to provide meaningful diagnostics. In order to obtain tha diagnostics you need to retrieve
IErrorInfo*
after the function retuns. Use code fromcheck()
function from the same example project for that. Just don't stare at the exception being thrown - you have no chances with that, let it propagate and be translated.