我在我的智慧結束。我有一個應用程序喜歡在NullReferenceException
(對象引用未設置爲對象實例)運行時崩潰幾分鐘。通常情況下,我可以處理這種情況,但是當Visual Studio發生故障時,它告訴我問題發生在Application.Run(new Main());
。我不知道該怎麼做才能開始解決這個問題。 Call Stack沒有任何幫助,因爲它只是指向Application.Run(new Main());
行。NullReferenceException在Application.Run(new Main())
我進入Visual Studio的異常窗口(CTRL + ALT + E
),並告訴它向我報告所有異常。我希望在我得到這個NullReferenceException
之前找到問題。但沒有運氣。
有哪些工具可以幫助我找到這個問題?
編輯:
這裏是調用堆棧報道由Visual Studio:
StackTrace:
at GMap.NET.WindowsForms.GMapOverlay.DrawRoutes(Graphics g)
at GMap.NET.WindowsForms.GMapOverlay.Render(Graphics g)
at GMap.NET.WindowsForms.GMapControl.OnPaintOverlays(Graphics g)
at GMap.NET.WindowsForms.GMapControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Foxhunt.Client.Program.Main() in C:\Users\Michael\Documents\Visual Studio 2010\Projects\Foxhunt.Client\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
請粘貼整個堆棧跟蹤。 – SLaks
此外,當您只是在Application.Run行和代碼的退出行上設置斷點時會發生什麼情況...如果有事情迫使您的應用程序重新啓動,那麼可能會顯示它... – Rikon
按請求添加的信息。我只能在應用程序第一次運行時斷開Application.Run。下次發生任何事情時,我得到'NullReferenceException'。 –