StackTrace Constructor (StackFrame)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the StackTrace class that contains a single frame.

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

public StackTrace(
	StackFrame frame
)

Parameters

frame
Type: System.Diagnostics.StackFrame

The frame that the StackTrace object should contain.

Use this constructor when you do not want the overhead of a full stack trace.

The following code example writes stack trace information to an event log entry.

StackFrame fr = new StackFrame(1,true);
StackTrace st = new StackTrace(fr);
EventLog.WriteEntry(fr.GetMethod().Name,
                    st.ToString(),
                    EventLogEntryType.Warning);

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