문제
이 코드는 C++프로젝트:
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 )
마지막 줄이 발생한 예외:
RPC 서버에서 사용할 수 없
할 수 있습니다 무엇을 일으키는 이 예외는?
해결책
ABBYY FRE COM 체입니다. GetEngineObject()
처럼 동작 일반 COM 인터페이스 방법을 제외하고 그것은 별도의 기능입니다.는 다음을 의미합니다:그것을 허용하지 않는 예외로 전파 외부.이를 달성하기 위해 그것을 잡는 모든 예외로 해석하는 적절한 HRESULT
값을 가능하게 설정 IErrorInfo
.
당신은 노력하고 분석하여 발생한 예외는 내부 메서드는 가능성은 없는 것을 찾는 문제입니다.기 때문에 내부적으로 일할 수 있습니다 다음과 같다:
HRESULT GetEngineObject( params )
{
try {
//that's for illustartion, code could be more comlex
initializeProtection( params );
obtainEngineObject( params );
} catch( std::exception& e ) {
setErrorInfo( e ); //this will set up IErrorInfo
return translateException( e ); // this will produce a relevant HRESULT
}
return S_OK;
}
void intializeProtection()
{
try {
doInitializeProtection();//maybe deep inside that exception is thrown
///blahblahblah
} catch( std::exception& e ) {
//here it will be translated to a more meaningful one
throw someOtherException( "Can't initialize protection: " + e.what() );
}
}
그래서 실제 호출을 잡을 수 있는 예외를 번역하고 그들을 제공하는 의미있는 진단을 수행합니다.를 얻기 위해서는 그쪽으로 진단할 필요가 검색 IErrorInfo*
후기능 retuns.사용 코드 check()
함수에서 예를 들어 프로젝트입니다.다만에 응시하지 않는 것을 제외하고 발생이 없을 기회를 가진 것 그것을 보자,전파과 번역될 수 있습니다.
제휴하지 않습니다 StackOverflow