Environment.StackTrace Özellik
Tanım
Geçerli yığın izleme bilgilerini alır.Gets current stack trace information.
public:
static property System::String ^ StackTrace { System::String ^ get(); };
public static string StackTrace { get; }
member this.StackTrace : string
Public Shared ReadOnly Property StackTrace As String
Özellik Değeri
Yığın izleme bilgilerini içeren bir dize.A string containing stack trace information. Bu değer olabilir Empty .This value can be Empty.
Örnekler
Aşağıdaki örnek, özelliğini gösterir StackTrace .The following example demonstrates the StackTrace property.
// Sample for the Environment::StackTrace property
using namespace System;
int main()
{
Console::WriteLine();
Console::WriteLine( "StackTrace: ' {0}'", Environment::StackTrace );
}
/*
This example produces the following results:
StackTrace: ' at System::Environment::GetStackTrace(Exception e)
at System::Environment::GetStackTrace(Exception e)
at System::Environment::get_StackTrace()
at Sample::Main()'
*/
// Sample for the Environment.StackTrace property
using System;
class Sample
{
public static void Main()
{
Console.WriteLine();
Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);
}
}
/*
This example produces the following results:
StackTrace: ' at System.Environment.GetStackTrace(Exception e)
at System.Environment.GetStackTrace(Exception e)
at System.Environment.get_StackTrace()
at Sample.Main()'
*/
' Sample for the Environment.StackTrace property
Class Sample
Public Shared Sub Main()
Console.WriteLine()
Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace)
End Sub
End Class
'
'This example produces the following results:
'
'StackTrace: ' at System.Environment.GetStackTrace(Exception e)
' at System.Environment.GetStackTrace(Exception e)
' at System.Environment.get_StackTrace()
' at Sample.Main()'
'
Açıklamalar
StackTraceÖzelliği, Yöntem çağrılarını ters kronolojik sırayla listeler, diğer bir deyişle, en son yöntem çağrısı ilk olarak açıklanmıştır ve yığın izleme bilgilerinin bir satırı yığındaki her yöntem çağrısı için listelenir.The StackTrace property lists method calls in reverse chronological order, that is, the most recent method call is described first, and one line of stack trace information is listed for each method call on the stack. Ancak, StackTrace özelliği iyileştirme sırasında oluşan kod dönüştürmeleri nedeniyle beklenen şekilde çok sayıda yöntem çağrısı bildiremeyebilir.However, the StackTrace property might not report as many method calls as expected due to code transformations that occur during optimization.
Not
Yığın izleme bilgilerinin sınıfa göre hiyerarşik bir görünümü için StackTrace sınıfını kullanın.For a hierarchical view of the stack trace information by class, use the StackTrace class.
StackTraceÖzelliği, her yöntem çağrısı için yığın izleme bilgilerini aşağıdaki gibi biçimlendirir:The StackTrace property formats the stack trace information for each method call as follows:
"at FullClassName
. MethodName
( MethodParams
) FileName
: Line LineNumber
""at FullClassName
.MethodName
(MethodParams
) in FileName
:line LineNumber
"
"At" değişmez değerinin önünde üç boşluk bulunur ve hata ayıklama sembolleri kullanılabilir değilse "ın" ile başlayan tüm alt dize atlanır.The literal "at" is preceded by three spaces, and the entire substring starting with "in" is omitted if debug symbols are not available. ,,,, Ve yer tutucular FullClassName
MethodName
MethodParams
FileName
LineNumber
gerçek değerlerle değiştirilmiştir ve aşağıdaki gibi tanımlanır:The placeholders, FullClassName
, MethodName
, MethodParams
, FileName
, and LineNumber
, are replaced by actual values, and are defined as follows:
FullClassName
Ad alanı dahil olmak üzere sınıfın tam adı.FullClassName
The full name of the class, including the namespace.
MethodName
Metodun adı.MethodName
The name of the method.
MethodParams
Parametre türü/ad çiftleri listesi.MethodParams
The list of parameter type/name pairs. Her bir çift virgül (",") ile ayrılır.Each pair is separated by a comma (","). MethodName
Hiçbir parametre alırsa bu bilgiler atlanır.This information is omitted if MethodName
takes no parameters.
FileName
Yöntemin bildirildiği kaynak dosyanın adı MethodName
.FileName
The name of the source file where the MethodName
method is declared. Hata ayıklama simgeleri kullanılabilir durumda değilse, bu bilgi atlanır.This information is omitted if debug symbols are not available.
LineNumber``FileName
MethodName
Çağrı yığınında olan yönerge için kaynak kodu içeren içindeki satırın numarası.LineNumber
The number of the line in FileName
that contains the source code from MethodName
for the instruction that is on the call stack. Hata ayıklama simgeleri kullanılabilir durumda değilse, bu bilgi atlanır.This information is omitted if debug symbols are not available.
Environment.NewLineDize, yığın izlemenin her satırını sonlandırır.The Environment.NewLine string terminates each line of the stack trace.