Ich habe zwei Beispiele. Im ersten Fall, fängt Debugger die nicht behandelte Ausnahme:Ausnahmen verlieren einen Teil von Stacktrace in Try/Catch-Kontext
static void Main(string[] args) {
Exec();
}
static void Exec() {
throw new Exception();
}
Und die Ausnahme hat die volle Stacktrace:
at ConsoleApplication28.Program.Exec()
at ConsoleApplication28.Program.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Der zweite Fall:
static void Main(string[] args) {
Exec();
}
static void Exec() {
try {
throw new Exception();
}
catch (Exception ex) {
} // Breakpoint
}
an der Unterbrechungs der Ausnahme kurze hat stacktrace:
at ConsoleApplication28.Program.Exec()
Warum werden Stacktraces im zweiten Fall in die containing-Methode geschnitten und wie kann man sie verhindern? Ich brauche full stacktrace für Bugreports, sonst ist es manchmal nicht möglich das Problem dort zu finden, ohne vollen Stacktrace.
"Ich brauche volle StackTrace für Bugreports, sonst ist es manchmal nicht möglich, dort das Problem zu finden, ohne vollen Stacktrace." Um diesen Teil Ihrer Frage zu beantworten, müssen Sie eine "try-catch" -Struktur irgendwo "oben" einfügen, wo Ausnahmen möglich sind, vielleicht ganz oben in Ihrer Main() -Methode. In der catch-Klausel sollten Sie die exceptionObject.ToString() in eine Datei oder etwas für eine spätere Analyse schreiben. – RenniePet