Export (0) Print
Expand All

InteropEHinCPP Sample: Demonstrates Catching a Common Language Runtime Exception in an Unmanaged C++ Application

Visual Studio .NET 2003

The InteropEHinCPP sample demonstrates catching a common language runtime exception thrown across a DLL boundary in C++ using the try-catch statement. Note that the exception is thrown in managed code and caught in unmanaged code.

Building and Running the Sample

To build and run InteropEHinCPP using Visual Studio

  1. In the Visual Studio IDE, load the solution file InteropEHinCPP.sln.
  2. In Solution Explorer, right-click the InteropEHinCPP solution.
  3. On the shortcut menu, click Build.
  4. On the Debug menu, click Start.

The following output is displayed in the console window:

.NET Framework exception code would be e0434f4d
Caught an exception -- code: e0434f4d
.NET Framework exception code will be e0434f4d
In TransFunc.
CMyException:
Error Code: e0434f4d
ExceptionRecord:
        ExceptionCode: e0434f4d
        ExceptionFlags: 1
        *ExceptionRecord: 00000000
        ExceptionAddress: 77E89B01
        NumberParameters: 0

**DONE**

Classes and Keywords

This sample demonstrates the following class:

Exception

This sample demonstrates the following keywords:

try, catch, __declspec(dllimport), EXCEPTION_RECORD, EXCEPTION_POINTERS, PEXCEPTION_POINTERS

See Also

Managed Extensions for C++ Samples

Show:
© 2014 Microsoft