Throwing com exceptions across process boundaries... 
Author Message
 Throwing com exceptions across process boundaries...

I have a COM exe and want to know if I throw com exceptions from this
component, can I use try/catch - in my client - to catch the exceptions.
Note that it is possible that the COM exe will run on a remote machine.  I
already have a connection point implemented and was wondering is this
another option for signaling the client that errors occur.

Demir



Tue, 29 Mar 2005 00:49:53 GMT  
 Throwing com exceptions across process boundaries...
That's not the way it works. The server returns an error HRESULT and,
optionally, sets up rich error info - see CComCoClass::Error,
AtlReportError, ISupportErrorInfo. The client receives the error HRESULT
and retrieves rich error info. If the client happens to use
#import-generated smart wrappers, they internally check for error
HRESULT, construct a _com_error object and throw it as a C++ exception,
so that you can handle the errors with try/catch

Again - COM excpetions are purely an artifact of using #import-generated
smart wrappers client-side. They are not part of COM specification. You
should never let any C++ exceptions escape from your server. Any errors
are reported via an HRESULT and rich error info.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I have a COM exe and want to know if I throw com exceptions from this
> component, can I use try/catch - in my client - to catch the
exceptions.
> Note that it is possible that the COM exe will run on a remote
machine.  I
> already have a connection point implemented and was wondering is this
> another option for signaling the client that errors occur.



Tue, 29 Mar 2005 01:30:30 GMT  
 Throwing com exceptions across process boundaries...
Gotcha. Thanks.


Quote:
> That's not the way it works. The server returns an error HRESULT and,
> optionally, sets up rich error info - see CComCoClass::Error,
> AtlReportError, ISupportErrorInfo. The client receives the error HRESULT
> and retrieves rich error info. If the client happens to use
> #import-generated smart wrappers, they internally check for error
> HRESULT, construct a _com_error object and throw it as a C++ exception,
> so that you can handle the errors with try/catch

> Again - COM excpetions are purely an artifact of using #import-generated
> smart wrappers client-side. They are not part of COM specification. You
> should never let any C++ exceptions escape from your server. Any errors
> are reported via an HRESULT and rich error info.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > I have a COM exe and want to know if I throw com exceptions from this
> > component, can I use try/catch - in my client - to catch the
> exceptions.
> > Note that it is possible that the COM exe will run on a remote
> machine.  I
> > already have a connection point implemented and was wondering is this
> > another option for signaling the client that errors occur.



Tue, 29 Mar 2005 06:58:22 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. _com_error thrown across machine boundaries

2. Exceptions Across DLL Boundaries?

3. IPicture across process boundaries

4. IXMLDOMNodeList across process boundaries?

5. Connection Point Events Across Processes Boundaries?

6. Can't pass IIDs properly across process boundaries

7. Passing Socket handles across process boundaries??

8. Can't pass IIDs properly across process boundaries

9. throwing exception from COM object's constructor

10. ATL COM DLL :: DllRegisterserver throw exception 0x80029c4a

11. throwing exception from COM and catching it in ASP

12. Throw exception from ATL COM for both VB and VC++ client

 

 
Powered by phpBB® Forum Software