Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StackFrame Constructor (Boolean)

 

Initializes a new instance of the StackFrame class, optionally capturing source information.

Namespace:   System.Diagnostics
Assembly:  mscorlib (in mscorlib.dll)

public:
StackFrame(
	bool fNeedFileInfo
)

Parameters

fNeedFileInfo
Type: System::Boolean

true to capture the file name, line number, and column number of the stack frame; otherwise, false.

The following example demonstrates the use of the StackFrame(Boolean) constructor. This code example is part of a larger example provided for the StackFrame class.


[STAThread]
static void Main()
{
   ClassLevel1 ^ mainClass = gcnew ClassLevel1;
   try
   {
      mainClass->InternalMethod();
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( " Main method exception handler" );

      // Display file and line information, if available.
      StackTrace^ st = gcnew StackTrace( gcnew StackFrame( true ) );
      Console::WriteLine( " Stack trace for current level: {0}", st->ToString() );
      Console::WriteLine( " File: {0}", st->GetFrame( 0 )->GetFileName() );
      Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() );
      Console::WriteLine();
      Console::WriteLine( "-------------------------------------------------\n" );
   }

}

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2017 Microsoft