Export (0) Print
Expand All

Rethrow Sample: Demonstrates Rethrowing a Common Language Runtime Exception and Catching It as a C++ Exception

Visual Studio .NET 2003

The Rethrow sample illustrates throwing an instance of System::Exception from a function. It then catches the common language runtime exception (System::Exception) and rethrows it. Finally, the rethrown exception is caught by a C++ catch block.

Building and Running the Sample

To build and run Rethrow using Visual Studio

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

The following output is displayed in the console window:

In handler 1
In handler 2

Classes and Keywords

This sample demonstrates the following class:

Exception

This sample demonstrates the following keywords:

try, catch, throw

See Also

Managed Extensions for C++ Samples

Show:
© 2014 Microsoft