Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages
Started by Dmitry Konnov
Sat, 27 May 2006 11:15
To Catch Exception incide of COM Automation Object
Author: Dmitry Konnov
Date: Sat, 27 May 2006 11:15
Date: Sat, 27 May 2006 11:15
10 lines
1038 bytes
1038 bytes
Hello, I want to trace all Exceptions inside my COM object. Application->OnExeption does not seem to work. Thank you. Dmitry
Re: To Catch Exception incide of COM Automation Object
Author: Remy Lebeau (TeamB)
Date: Sat, 27 May 2006 20:39
Date: Sat, 27 May 2006 20:39
34 lines
2108 bytes
2108 bytes
"Dmitry Konnov" <dmitry@weblinedesign.biz> wrote in message
news:447835f3@newsgroups.borland.com...
> I want to trace all Exceptions inside my COM object.
COM methods are not allowed to let exceptions pass into the application. To
do so is undefined behavior, since the COM object has no way to know what
programming language is being used to access the object, and that language
may not be able to handle the exception properly at all (VB can't handle
Delphi exceptions, etc). Every COM method that you expose access to for the
application to call should have its own try..catch block inside of itself,
ie:
HRESULT __stdcall TMyIntfImpl::DoSomething()
{
try
{
// do the work here ...
}
catch(const Exception &e)
{
return Error(E.Message.c_str(), IID_IMyIntf, E_UNEXPECTED);
}
return S_OK;
}
This way, if an exception occurs inside a COM method, the Error() method
will assign values that the application can retreive via the IErrorInfo
interface. You can then focus your debugging in that particular method to
narrow down why it crashed in the first place.
Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads