How to see stacktrace .NET application

I have a .NET Windows application in production that does not have access to Visual Studio (standard version), and the only thing they can install is the Express version , which does not have the option "Debug on time" (the one that has a debug button when it crashes). So I'm just wondering if there is a Windows application debugging tool or something else that I can run or attach to see stacktraces. I also included PDB in my application, but it does not provide more information, so I can track my failures (caused by unhandled exceptions).

+3
source share
6 answers

You can also use windbg and sos.dll

+3
source

If you catch exceptions, the Exception object contains a stack trace: Exception.StackTrace . In addition, you have access to it with Environment.StackTrace .

The code below also has an event handler for unhandled exceptions that 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);
    }
+6
source
+1

Perhaps EQATEC Tracer can help you.

0
source

Using:

The .NET Framework 2.0 SDK comes with the Microsoft CLR debugger. It works similarly to the Visual Studio debugger (although the source files are read-only), so you can try it.

0
source

Source: https://habr.com/ru/post/1721342/


All Articles