StackTrace Class

StackTrace Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Represents a stack trace, which is an ordered collection of one or more stack frames.

System::Object
  System.Diagnostics::StackTrace

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

No code example is currently available or this language may not be supported.

The StackTrace type exposes the following members.

  NameDescription
Public methodStackTrace()Initializes a new instance of the StackTrace class from the caller's frame.
Public methodStackTrace(Boolean)Security Critical. Initializes a new instance of the StackTrace class from the caller's frame, and optionally captures source information.
Public methodStackTrace(Exception)Initializes a new instance of the StackTrace class by using the specified exception object.
Public methodStackTrace(Int32)Security Critical. Initializes a new instance of the StackTrace class from the caller's frame, skipping the specified number of frames.
Public methodStackTrace(StackFrame)Initializes a new instance of the StackTrace class that contains a single frame.
Public methodStackTrace(Exception, Boolean)Security Critical. Initializes a new instance of the StackTrace class by using the specified exception object, and optionally captures source information.
Public methodStackTrace(Exception, Int32)Security Critical. Initializes a new instance of the StackTrace class by using the specified exception object and skipping the specified number of frames.
Public methodStackTrace(Int32, Boolean)Security Critical. Initializes a new instance of the StackTrace class from the caller's frame, skipping the specified number of frames and optionally capturing source information.
Public methodStackTrace(Thread, Boolean) Obsolete. Security Critical. Initializes a new instance of the StackTrace class for a specific thread, and optionally captures source information.
Public methodStackTrace(Exception, Int32, Boolean)Security Critical. Initializes a new instance of the StackTrace class by using the specified exception object and skipping the specified number of frames, and optionally captures source information.
Top

  NameDescription
Public propertyFrameCountGets the number of frames in the stack trace.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetFrameGets the specified stack frame.
Public methodGetFramesReturns a copy of all stack frames in the current stack trace.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringBuilds a readable representation of the stack trace. (Overrides Object::ToString().)
Top

  NameDescription
Public fieldStatic memberMETHODS_TO_SKIPDefines the default for the number of methods to omit from the stack trace. This field is constant.
Top

StackTrace information will be most informative with debug build configurations. By default, debug builds include debug symbols, but release builds do not. The debug symbols contain most of the file, method name, line number, and column information that is used in constructing StackFrame and StackTrace objects.

StackTrace might not report as many method calls as expected, because of code transformations that occur during optimization.

Version Notes

Windows Phone

 StackTrace is not supported in Windows Phone.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2017 Microsoft