开发者

How to get Exception details without debugger?

开发者 https://www.devze.com 2023-02-01 21:07 出处:网络
I\'m testing a .net 4 application on a stock windows install and get a crash as it starts up. The \"View problem details\" from the error dialog tells me that its a System.IO.FileNotFoundException bu

I'm testing a .net 4 application on a stock windows install and get a crash as it starts up. The "View problem details" from the error dialog tells me that its a System.IO.FileNotFoundException but does not show the exception data so I have no idea what file it's trying to load.

Is there a way to get some more 开发者_JS百科detailed data about the exception without installing visual studio?


Write an event handler for AppDomain.CurrentDomain.UnhandledException. Log or display the value of e.ExceptionObject.ToString() to get the exception message and the stack trace.


You could use ProcMon to Monitor your application to find out wich file it tries to find. (When starting Procmon you should filter out every thing else before starting your App)


You can also try looking at the Windows Event Log. For example, a quick search on my machine found the following error from MetroTwit (a .NET Twitter client):

Application: MetroTwit.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
   at System.Windows.Application.GetResourcePackage(System.Uri)
   at System.Windows.Application.LoadComponent(System.Object, System.Uri)
   at MetroTwit.View.ErrorView.InitializeComponent()
   at MetroTwit.View.ErrorView..ctor(System.String)
   at MetroTwit.App.Application_DispatcherUnhandledException(System.Object,     System.Windows.Threading.DispatcherUnhandledExceptionEventArgs)
   at System.Windows.Threading.Dispatcher.CatchException(System.Exception)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object,         
    System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, 
    Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.InvokeImpl(
    System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, 
    System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(
    System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run()
   at MetroTwit.App.Main()

The error level was Error and the source was ".NET Runtime"

0

精彩评论

暂无评论...
验证码 换一张
取 消