Re: catching unmanaged exceptions in managed code, not working in release build
From: Vasco Lohrenscheit (valohNOSPAM_at_web.de)
Date: 07/30/04
- Next message: Carl Daniel [VC++ MVP]: "Re: Regex library"
- Previous message: Steve McLellan: "Re: Regex library"
- In reply to: Steve McLellan: "Re: catching unmanaged exceptions in managed code, not working in release build"
- Next in thread: Steve McLellan: "Re: catching unmanaged exceptions in managed code, not working in release build"
- Reply: Steve McLellan: "Re: catching unmanaged exceptions in managed code, not working in release build"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 30 Jul 2004 15:57:52 +0200
Steve McLellan wrote:
> Have a look at SEHException - it allows you to retrieve info related to the
> original exception (see MSDN for
> System::Runtime::InteropServices::SEHException).
>
> What's unusual is that you were able to catch the std::exception at all. I
> don't know how this stands to change in the future; I'm writing production
> code so haven't used any of the 2005 beta releases.
> Also see this, and have a Google for information about exception handling in
> mixed C++.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcconBasicConceptsInUsingManagedExceptions.asp
mhh, if I understand the section "Catching Unmanaged C++ Types"
correctly, a catch(const std::exception& e) should work:
" * If an unmanaged C++ type is encountered, the exception is
unwrapped and compared to the type encountered. This comparison allows
an unmanaged C++ type to be caught in the normal way.
* However, if a catch clause of type SEHException or any of its
base classes is examined first, the clause will intercept the exception.
Therefore, you should place all catch clauses that catch unmanaged C++
types first before any catch clauses of managed types.
"
After some testing I've found several problems: The exceptions are only
catched if I debug with F5. Running without debugging neither in the
release nor in the debug build the exceptions are catched. I also tried
to catch the System::Runtime::InteropServices::SEHException and
System::Exception but they aren't catched neither.
But I have enabled the compiler option for exceptions (/EHsc) and
catching exceptions within the unmanaged code works fine.
Any ideas what can cause this strange behaviour? Could it be a problem
that the exceptions are thrown/catched across dll boundaries?
best regards,
Vasco Lohrenscheit
- Next message: Carl Daniel [VC++ MVP]: "Re: Regex library"
- Previous message: Steve McLellan: "Re: Regex library"
- In reply to: Steve McLellan: "Re: catching unmanaged exceptions in managed code, not working in release build"
- Next in thread: Steve McLellan: "Re: catching unmanaged exceptions in managed code, not working in release build"
- Reply: Steve McLellan: "Re: catching unmanaged exceptions in managed code, not working in release build"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|