I have a .NET Windows application in the production that has no access to Visual Studio (standard edition), and the only thing they can install is the Express edition, which does not have the Just-In-Time Debugging option (the one which has the debug button when it crashes). So I was just wondering if there is a Windows application debugging tool or something else that I can run or attach to see stacktraces. I also enabled PDB in my application, but it does not provide any more information, so I can trace my crashes (caused by unhandled exceptions).
If you are catching exceptions, the Exception object contains the stack trace: Exception.StackTrace. Also, you have access to it with Environment.StackTrace.
In the code below there is also an event handler for unhandled exceptions which will write the exception, including the stack trace, to the event log.
// Sample for the Environment.StackTrace property
using System;
class Sample
{
public static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(UnhandledExceptions);
Console.WriteLine("StackTrace: '{0}'", Environment.StackTrace);
throw new Exception("Fatal Error");
}
static void UnhandledExceptions(object sender, UnhandledExceptionEventArgs e)
{
string source = "SOTest";
if (!System.Diagnostics.EventLog.SourceExists(source))
{
System.Diagnostics.EventLog.CreateEventSource(source, "Application");
}
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = source;
log.WriteEntry(e.ExceptionObject.ToString(),
System.Diagnostics.EventLogEntryType.Error);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With