Thanks Guys!

Tom

> -----Original Message-----
> From: Myles Penlington [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 21, 1999 9:00 PM
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Threads and COM
> 
> 
> Use the ServerExceptionHandler .. This is called when ever a exception
> propagates out of a method marked as SafeCall.
> 
> Remember all COM and hence SAFECALL's calls are actually 
> function calls that
> return HRESULT, so exceptions do not get propagated out of a 
> COM object,
> they are caught by the try except block around the method 
> call and changed
> into HRESULT code to be passed back to the caller.
> 
> All our COM objects implement these and log any exceptions 
> caught in the NT
> event log.
> 
> eg
> 
> procedure TMyComObject.AfterConstruction;
> begin
>   inherited;
>   ServerExceptionHandler := TMyExceptionHandler.Create;
> end;
> 
> procedure TMyComObject.BeforeDestruction;
> begin
>   ServerExceptionHandler := nil;
>   inherited;
> end;
> 
>     TMyExceptionHandler = class(TInterfacedObject, 
> IServerExceptionHandler)
>         procedure OnException(
>             const ServerClass, ExceptionClass, ErrorMessage: 
> WideString;
>             ExceptAddr: Integer; const ErrorIID, ProgID: WideString;
>             var Handled: Integer; var Result: HResult);
>   end;
> 
> procedure TMyExceptionHandler.OnException(const ServerClass, 
> ExceptionClass,
>   ErrorMessage: WideString; ExceptAddr: Integer; const ErrorIID,
>   ProgID: WideString; var Handled: Integer; var Result: HResult);
> begin
>   //Handle the exception however you want to ...
> 
>   // Do not pass the message onto the OS's COM subsystem - 
> however you can
> if you want to.
>   Handled := Integer( True );
> end;
> > -----Original Message-----
> > From:       Tom Munro Glass [SMTP:[EMAIL PROTECTED]]
> > Sent:       Tuesday, 21 December 1999 04:07
> > To: Multiple recipients of list delphi
> > Subject:    [DUG]:  Threads and COM
> > 
> > Can someone please give me some tips for exception handling 
> in a COM-based
> > application?
> > 
> > The application uses a number of in-process and out-of-process COM
> > servers,
> > and exceptions are occurring but the 
> Application.OnException event is not
> > getting called. The result is that the application displays an error
> > message
> > and then terminates without me having a chance of dealing 
> with the source
> > of
> > the exception.
> > 
> > I see that the application has several threads (I'm not creating any
> > threads
> > directly), so I assume that these are being created by COM. 
> I suspect that
> > the exceptions are occurring in one of these threads, but 
> how do I go
> > about
> > catching these?
> > 
> > ==================================================================
> > 
> > Tom Munro Glass
> > 
> > +----------------------------------------------------------------+
> > | E-mail:                                                        |
> > |     Internet:           [EMAIL PROTECTED]                         |
> > | Web sites:                                                     |
> > |     TMG CONSULTANCY:    http://www.tmgcon.com                  |
> > |     Tewkesbury Web:     http://www.tmgcon.com/tewksweb         |
> > +----------------------------------------------------------------+
> > 
> > 
> --------------------------------------------------------------
> ------------
> > -
> >     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to