views:

346

answers:

7

Hi,

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 debug button when it crashes). So I was just wondering if there is a window application debugging tool or something else that I can run or attach to see stacktraces. I also enabled Pbd in my application, but it does not provide any more information, so I can trace my crashes (caused by unhandled exceptions)

Any help or comment would be highly appreciated.

thanks,

+1  A: 

You could try the CLR Profiler

Manu
Does it give a nice output for the content of Stacktrace? like class and line number, cause my crashes are unhandled ones.
paradisonoir
@paradisonoir: Fyi, line numbers are only available if you have the pdb of the assemblies. Else, you'll just get the stack location and method names.
eduncan911
+1 for mentioning a free profiler that solves the OP's problem, namely displaying the stacktrace. For the record, here's a link to CLR Profiler 2.0: http://tinyurl.com/ClrProfiler2
galaktor
+1  A: 

You can also use windbg and sos.dll

Matt Wrock
That can be hard for even intermediate developers. Maybe they can use DebugDiag or other tools to generate a crash dump and analyze with WinDbg. Then a simple "analyze -v" is enough to print out exception information.
Lex Li
Is it possible to produce the line number from Windbg? Cause I can get the method name, but not the line number.
paradisonoir
Only if you have symbols and I THINK it has to be built in debug mode too.
Matt Wrock
A: 

Maybe the EQATEC Tracer could help you out.

Tinister
I started my application with it, but it does not have any output of my stacktrace after a crash occurs.
paradisonoir
+2  A: 

If you are catching exceptions, the Exception object contains the stack trace: Exception.StackTrace. Also, you have access to it with Environment.StackTrace.

EDIT: Added unhandled exception event which will write the exception, including 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);
}
Philip Wallace
so can I print out some unhanded exception as well?
paradisonoir
Yes. You could use logging frameworks to write them to error logs too.
Jon Limjap
@paradisonoir - I added an unhandled exception event handler, which writes the log (including stack trace) to the event log.
Philip Wallace
+1  A: 
eduncan911
I think you will find they only end up here if you log them yourself, when an exception is thrown!
Philip Wallace
I get exceptions in my apps, that I do not handle showing here.
eduncan911
My ASP.net applications also automatically log unhandled exceptions to the eventlog. No code needed.
Cloud
Well, I am running a Window Application, so do you think it can be helpful for them as well. My crashes are for unhandled exceptions though
paradisonoir
Ah crap, I missed that part (using Windows App). I do not have enough experience to know if windows apps will show up in the event viewer. I would imagine it does. Just take a quick look.
eduncan911
For WinForms or WPF applications, event log entries are different, and call stacks are not available.
Lex Li
Call stacks are available, but have to be logged manually.
Philip Wallace
Philip, what do you mean by "should be logged manually"?
paradisonoir
A: 

http://www.microsoft.com/downloads/thankyou.aspx?familyId=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displayLang=en

http://www.microsoft.com/downloads/thankyou.aspx?familyId=1aef6fce-6e06-4b66-afe4-9aad3c835d3d&displayLang=en

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

Lex Li
You can also add global exception handlers to your application. http://blogs.msdn.com/lexli/archive/2009/04/28/how-to-handle-net-unhandled-exceptions-gracefully.aspx
Lex Li
A: 

YourKit .NET Profiler http://www.yourkit.com/dotnet/ can show you thread states and stacks of all running threads. Take a look at the picture

Serge
That's a nice tool, but it does not give you enough detail such as stacktrace.
paradisonoir
It does give stack traces. Take a look at the bottom view http://www.yourkit.com/docs/net45/help/threads.jsp Just select point of time of telemetry graph and you'll see stacktraces of all running threads
Serge