This documentation is archived and is not being maintained.

StackFrame Class

Provides information about a StackFrame, which represents a function call on the call stack for the current thread.

System.Object
  System.Diagnostics.StackFrame

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

[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
[<SecurityPermissionAttribute(SecurityAction.InheritanceDemand, UnmanagedCode = true)>]
type StackFrame =  class end

The StackFrame type exposes the following members.

  NameDescription
Public methodStackFrame()Initializes a new instance of the StackFrame class.
Public methodStackFrame(Boolean)Initializes a new instance of the StackFrame class, optionally capturing source information.
Public methodStackFrame(Int32)Initializes a new instance of the StackFrame class that corresponds to a frame above the current stack frame.
Public methodStackFrame(Int32, Boolean)Initializes a new instance of the StackFrame class that corresponds to a frame above the current stack frame, optionally capturing source information.
Public methodStackFrame(String, Int32)Initializes a new instance of the StackFrame class that contains only the given file name and line number.
Public methodStackFrame(String, Int32, Int32)Initializes a new instance of the StackFrame class that contains only the given file name, line number, and column number.
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 it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetFileColumnNumberGets the column number in the file that contains the code that is executing. This information is typically extracted from the debugging symbols for the executable.
Public methodGetFileLineNumberGets the line number in the file that contains the code that is executing. This information is typically extracted from the debugging symbols for the executable.
Public methodGetFileNameGets the file name that contains the code that is executing. This information is typically extracted from the debugging symbols for the executable.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetILOffsetGets the offset from the start of the Microsoft intermediate language (MSIL) code for the method that is executing. This offset might be an approximation depending on whether or not the just-in-time (JIT) compiler is generating debugging code. The generation of this debugging information is controlled by the DebuggableAttribute.
Public methodGetMethodGets the method in which the frame is executing.
Public methodGetNativeOffsetGets the offset from the start of the native just-in-time (JIT)-compiled code for the method that is being executed. The generation of this debugging information is controlled by the DebuggableAttribute class.
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 memberOFFSET_UNKNOWNDefines the value that is returned from the GetNativeOffset or GetILOffset method when the native or Microsoft intermediate language (MSIL) offset is unknown. This field is constant.
Top

A StackFrame is created and pushed on the call stack for every function call made during the execution of a thread. The stack frame always includes MethodBase information, and optionally includes file name, line number, and column number information.

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

The following example demonstrates the use of the StackFrame class to provide the stack frame information for a stack trace.

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

The following example demonstrates the use of the members of the StackFrame class.

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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: