Export (0) Print
Expand All

StackFrame.GetILOffset Method

Gets 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 the just-in-time (JIT) compiler is generating debugging code or not. The generation of this debugging information is controlled by the DebuggableAttribute.

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

public virtual int GetILOffset ()
public int GetILOffset ()
public function GetILOffset () : int
Not applicable.

Return Value

The offset from the start of the MSIL code for the method that is executing.

The following example demonstrates the use of the GetILOffset method.

// Display the stack frame properties.
StackFrame sf = st.GetFrame(i);
Console.WriteLine(" File: {0}", sf.GetFileName());
Console.WriteLine(" Line Number: {0}", 
   sf.GetFileLineNumber());
// Note that the column number defaults to zero
// when not initialized.
Console.WriteLine(" Column Number: {0}", 
   sf.GetFileColumnNumber());
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
   Console.WriteLine(" Intermediate Language Offset: {0}", 
      sf.GetILOffset());
}
if (sf.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN)
{
   Console.WriteLine(" Native Offset: {0}", 
      sf.GetNativeOffset());
}

// Display the stack frame properties.
StackFrame sf = st.GetFrame(i);
Console.WriteLine(" File: {0}", sf.GetFileName());
Console.WriteLine(" Line Number: {0}", (
    Int32)sf.GetFileLineNumber());

// Note that the column number defaults to zero
// when not initialized.
Console.WriteLine(" Column Number: {0}", 
    (Int32)sf.GetFileColumnNumber());
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN) {
    Console.WriteLine(" Intermediate Language Offset: {0}", 
        (Int32)sf.GetILOffset());
}
if (sf.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN) {
    Console.WriteLine(" Native Offset: {0}", 
        (Int32)sf.GetNativeOffset());
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft