paradisonoir
paradisonoir

Reputation: 2910

How to see the stacktrace of a .NET application

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).

Upvotes: 4

Views: 9950

Answers (6)

eduncan911
eduncan911

Reputation: 17604

The stacktraces of .NET application exceptions are logged in your Event Viewer under Applications.

This link throws a 404:

alt text http://eduncan911.com/blog/thumbnail/exception-in-iis-stackoverflow-logs.png

Upvotes: 1

Lex Li
Lex Li

Reputation: 63143

Use:

.NET Framework 2.0 SDK ships with Microsoft CLR Debugger. It works similar to Visual Studio debugger (though source files are readonly), so you can give it a try.

Upvotes: 0

Philip Wallace
Philip Wallace

Reputation: 8015

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);
    }

Upvotes: 6

Tinister
Tinister

Reputation: 11487

Maybe the EQATEC Tracer could help you out.

Upvotes: 0

Matt Wrock
Matt Wrock

Reputation: 6640

You can also use windbg and sos.dll

Upvotes: 3

Manu
Manu

Reputation: 29143

You could try the CLR Profiler

Upvotes: 1

Related Questions