🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #609

Re: How catch an exception from a DLL?

#609
From: Marc Rohloff TeamB
Date: Fri, 02 Jul 2004 12:36
25 lines
1819 bytes
On Fri, 2 Jul 2004 02:15:01 +0200, RB wrote:

> I have a DLL written in Delphi. Here I raises an exception.
> In the calling method I catches the exception, and then would like to handle
> the exception.
> The caught exception turns out to always be a SEHException, with
> apparently no information about the actual raised exception.
> What can I do?

Redefine the method to be safecall instead of stdcall. 

Modify the DllImport attribute in c# with PrserveSig=false.

Wrap your Delphi function with an exception handler. When you get an
exception setup the correct IErrorInfo that you want and reraise the
exception.

There is a fair bitof information about setting up IErrorInfo on the
web. You can also look at the way Delphi does it. Start at the
SafeCallException method, poke around in comobject.pas.  IIRC you may
be able to use some of the code as is.

-- 
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com
Technical Details
Message-ID: <193bdpxktzyux.dlg@marcrohloff.40tude.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40e4a93f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,af37c7da03bedca2
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Marc Rohloff [TeamB]" <"on request">
Subject: Re: How catch an exception from a DLL?
Newsgroups: borland.public.csharpbuilder.language.csharp
User-Agent: 40tude_Dialog/2.0.12.1
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
References: <40e4a93f$1@newsgroups.borland.com>
Date: Fri, 2 Jul 2004 08:36:07 -0400
Message-ID: <193bdpxktzyux.dlg@marcrohloff.40tude.net>
NNTP-Posting-Host: 4.131.32.180
X-Trace: newsgroups.borland.com 1088771686 4.131.32.180 (2 Jul 2004 05:34:46 -0700)
Lines: 25
X-Authenticated-User: mrohloff
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail