Re: Unmanaged exception caught how in managed code?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Hendrik Schober (SpamTrap_at_gmx.de)
Date: 02/09/04


Date: Mon, 9 Feb 2004 10:44:43 +0100

Mhmm. While catching by reference certainly
is better than catching by value (beeing
who I am I mostly catch by const reference),
actually I was refereing to your
  throw new S()
as this begs the question of who will be
responsible for deleting the object.

Schobi

Yan-Hong Huang[MSFT] <yhhuang@online.microsoft.com> wrote:
> Hi Schobi,
>
> You are correct. This is just extracted from some sample code. throw S()
> --> catch (S& s) is better.
>
> While the Standard doesn't specify where the exception object in catch (xc
> & x) is stored, most implementation maintain a special exception stack, on
> which exception are constructed (however, the Standard does not allow the
> implementation to use free store memory for that purpose). Passing an
> exception by reference is preferred to passing an exception by value for
> several reasons: as you suggested, it short circuits the process of passing
> the exception object to its handler (only a reference is copied rather than
> a full-blown object). However, pass by reference also ensures that derived
> exceptions are not sliced. Finally, it enables you to modify the exception
> and then pass it on to another handler (i.e., a re-throw) with the changes
> made to that object.
>
> Thanks for pointing it out. :)
>
> Best regards,
> Yanhong Huang
> Microsoft Community Support
>
> Get Secure! ¨C www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.

-- 
SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org
"Sometimes compilers are so much more reasonable than people."
  Scott Meyers


Relevant Pages

  • Re: Derived type argument to subroutine
    ... In practice, they often, but not always are. ... I can rely on the fact that arguments are passed by reference. ... Would the printed value always be 4, or is it undefined as the passing ... With an important exception, ...
    (comp.lang.fortran)
  • Re: Dataset retunring Null ..a gurus opinion required!
    ... How is estateOleAdapter initialized? ... toolbox to the design area to establish the connection. ... application this exception comes up): ... When adding a reference, I tried "Add Service Reference" and I also ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: "invalid handle", sockets, threads and garbage collector
    ... your IntPtr value happens to coincide with a reference. ... The exception contains "invalid handle" message. ... Socket constructor problem ... finalization means closing the handle to resource. ...
    (microsoft.public.dotnet.framework.clr)
  • Global Assembly Cache Issue
    ... I have a dll that I use in several projects, that I placed in the Global ... you can see in the Exception below). ... If I change the Copy Local property of the reference to True, ... Attempting download of new URL ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: newbie: deactivate query before freeing?
    ... but the exception will still be thrown. ... There is exactly one invalid reference, the null pointer, nil. ... abort the normal flow of execution and start handling the exception ...
    (comp.lang.pascal.delphi.misc)