This documentation is archived and is not being maintained.

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

Visual Studio .NET 2003

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

Building and Running the Sample

To build and run InteropEHinC using Visual Studio

  1. In the Visual Studio IDE, load the solution file InteropEHinC.sln.
  2. In Solution Explorer, right-click the InteropEHinC 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

Classes and Keywords

This sample demonstrates the following class:

Exception

This sample demonstrates the following keywords:

__try, __except

See Also

Managed Extensions for C++ Samples

Show: