I have a COM server written in MSVC 6 C++. If I use a C++ client and get an error my server will give back error information using IErrorInfo. So if the client calls a method that throws a com_error exception the following will find out what's gone wrong...
But when calling the same method on the server (and expecting the same error) from a C# client using catch (COMException e) then e.Message is
"Error HRESULT E_FAIL has been returned from a call to a COM component."
rather than what GetDescription( ) returns.
Any idea where to start looking?
Code:
ReportErrorInfo(IUnknown * punk){ USES_CONVERSION; CComBSTR bstrError; CComPtr<ISupportErrorInfo> pSEI; if (!punk) { strcpy(ErrorMessage,"No interface to COM server"); } else try { HRESULT hr = punk->QueryInterface(IID_ISupportErrorInfo,(void **) &pSEI); if(SUCCEEDED(hr)) { CComPtr<IErrorInfo> pEO; if(S_OK == ::GetErrorInfo(NULL, &pEO)) { CComBSTR bstrDesc; pEO->GetDescription(&bstrDesc); strcpy(ErrorMessage,OLE2T(bstrDesc)); // something useful in ErrorMessage by now ...
"Error HRESULT E_FAIL has been returned from a call to a COM component."
rather than what GetDescription( ) returns.
Any idea where to start looking?
Comment