Catching unmanaged exceptions in MC++ 
Author Message
 Catching unmanaged exceptions in MC++

I have an unmanaged C++ class, with a managed C++ wrapper class. If I do a
normal C++ style throwing of an exception in the unmanaged code, can I catch
it in a .NET stylee in the managed class?

--
Regards,

http://www.*-*-*.com/
GPG Key Fingerprint : 78C6 D057 EAB8 1E70
                                   5365 F561 C38A C88D
                                   DDA9 119B



Mon, 21 Feb 2005 15:49:41 GMT  
 Catching unmanaged exceptions in MC++
Yes, you can we wrap and unwrap exceptions between the managed and native
exception types automatically.

Ronald Laeremans
Visual C++ compiler and libraries team


Quote:
> I have an unmanaged C++ class, with a managed C++ wrapper class. If I do a
> normal C++ style throwing of an exception in the unmanaged code, can I
catch
> it in a .NET stylee in the managed class?

> --
> Regards,

> http://4space.org.uk
> GPG Key Fingerprint : 78C6 D057 EAB8 1E70
>                                    5365 F561 C38A C88D
>                                    DDA9 119B



Tue, 22 Feb 2005 00:57:21 GMT  
 Catching unmanaged exceptions in MC++

Quote:
> I have an unmanaged C++ class, with a managed C++ wrapper class. If I do a
> normal C++ style throwing of an exception in the unmanaged code, can I
catch
> it in a .NET stylee in the managed class?

Ronald's answer is, of course, correct (and it works very nicely, too).

However, let me add that if you're going to be using your MC++ code from
other .NET languages, you might want to expose more rich error information
in your exceptions, as it's very likely that your unmanaged C++ exception
objects carry additional information.

In those cases, what I do is create a few new managed Exception classses
derived from ApplicationException, and use them to wrap my unmanaged
exception objects at the managed<->unmanaged transition layer by extrating
the extra information and making it available via properties and ToString().
It works very nicely,

--
Tomas Restrepo



Thu, 24 Feb 2005 22:56:21 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Handling unmanaged exceptions in MC++

2. MC++ wrapper for unmanaged static resource

3. Problems to pass HWND from c# client to unmanaged vc++ class via MC++ warpper

4. Catching Win32 exceptions with a C++ catch-block

5. Q: Why try catch cannot catch the exception

6. Catching hardware exceptions using C++ exceptions

7. Catching SEC Exceptions as C++ Exceptions

8. Exception across managed/unmanaged

9. managed C++ wrapper around unmanaged C++ classes: causing StackOverflow exception

10. Exceptions Crossing Managed-Unmanaged Boundaries

11. problem of unmanaged exception in managed code C++

12. exceptions in unmanaged c++ in .NET ide

 

 
Powered by phpBB® Forum Software