Exportar (0) Imprimir
Expandir todo

StackFrame (Constructor) (Int32)

Inicializa un nuevo objeto StackFrame correspondiente a un marco situado por encima del marco de pila actual.

Espacio de nombres: System.Diagnostics
Ensamblado: mscorlib (en mscorlib.dll)

public StackFrame (
	int skipFrames
)
public StackFrame (
	int skipFrames
)
public function StackFrame (
	skipFrames : int
)

Parámetros

skipFrames

Número de marcos por encima de la pila que se deben omitir.

En el ejemplo de código siguiente, se muestra el uso de un constructor de StackFrame.

public void InternalMethod()
{
   try
   {
      ClassLevel2 nestedClass = new ClassLevel2();
      nestedClass.Level2Method();
   }
   catch (Exception e)
   {
      Console.WriteLine(" InternalMethod exception handler");

      // Build a stack trace from one frame, skipping the
      // current frame and using the next frame.  By
      // default, file and line information are not displayed.
      StackTrace st = new StackTrace(new StackFrame(1));
      Console.WriteLine(" Stack trace for next level frame: {0}",
         st.ToString());
      Console.WriteLine(" Stack frame for next level: ");
      Console.WriteLine("   {0}", st.GetFrame(0).ToString());

      Console.WriteLine(" Line Number: {0}",
         st.GetFrame(0).GetFileLineNumber().ToString());

      Console.WriteLine();
      Console.WriteLine("   ... throwing exception to next level ...");
      Console.WriteLine("-------------------------------------------------\n");
      throw e;
   }
}

public void InternalMethod() throws System.Exception
{
    try {
        ClassLevel2 nestedClass = new ClassLevel2();
        nestedClass.Level2Method();
    }
    catch (System.Exception e) {
        Console.WriteLine(" InternalMethod exception handler");

        // Build a stack trace from one frame, skipping the
        // current frame and using the next frame.  By
        // default, file and line information are not displayed.

        StackTrace st = new StackTrace(new StackFrame(1));
        Console.WriteLine(" Stack trace for next level frame: {0}", 
            st.ToString());
        Console.WriteLine(" Stack frame for next level: ");
        Console.WriteLine("   {0}", st.GetFrame(0).ToString());
        Console.WriteLine(" Line Number: {0}", 
            Convert.ToString(st.GetFrame(0).GetFileLineNumber()));
        Console.WriteLine();
        Console.WriteLine(" ... throwing exception to next level...");
        Console.WriteLine("-------------------------------------------"
            + "------\n");
        throw e;
    }
} //InternalMethod

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

.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.

.NET Framework

Compatible con: 2.0, 1.1, 1.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft