StackTrace Class

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

Inheritance Hierarchy

System.Object
  System.Diagnostics.StackTrace

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

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Class StackTrace
[ComVisibleAttribute(true)]
public class StackTrace

The StackTrace type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace() Initializes a new instance of the StackTrace class from the caller's frame.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(Boolean) Security Critical. Initializes a new instance of the StackTrace class from the caller's frame, and optionally captures source information.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(Exception) Initializes a new instance of the StackTrace class by using the specified exception object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(Int32) Security Critical. Initializes a new instance of the StackTrace class from the caller's frame, skipping the specified number of frames.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(StackFrame) Initializes a new instance of the StackTrace class that contains a single frame.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(Exception, Boolean) Security Critical. Initializes a new instance of the StackTrace class by using the specified exception object, and optionally captures source information.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(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 methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(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 methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(Thread, Boolean) Security Critical. Initializes a new instance of the StackTrace class for a specific thread, and optionally captures source information.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 StackTrace(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

Properties

  Name Description
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 FrameCount Gets the number of frames in the stack trace.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetFrame Gets the specified stack frame.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetFrames Returns a copy of all stack frames in the current stack trace.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString Builds a readable representation of the stack trace. (Overrides Object.ToString().)

Top

Fields

  Name Description
Public fieldStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 METHODS_TO_SKIP Defines the default for the number of methods to omit from the stack trace. This field is constant.

Top

Remarks

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.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 StackTrace is not supported in Silverlight for Windows Phone.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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