【发布时间】:2012-12-07 03:37:27
【问题描述】:
我无计可施。我有一个应用程序,它喜欢在运行 NullReferenceException 时崩溃几分钟(对象引用未设置为对象的实例)。通常我可以很好地处理这个问题,但是当 Visual Studio 爆发时,它告诉我问题发生在Application.Run(new Main());。我不知道该怎么做才能开始解决这个问题。调用堆栈没有任何帮助,因为它只是指向 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()
【问题讨论】:
-
请粘贴整个堆栈跟踪。
-
在“异常”对话框中选择 NullReferenceException:抛出异常时 - 进入调试器。
-
您在表单中使用了非 .NET 控件,可能是 ActiveX 控件。您需要启用非托管调试并打开 Microsoft 符号服务器才能查看更多信息。
-
禁用仅我的代码并再次查看调用堆栈。还要查看 exception 的堆栈跟踪。
-
@SLaks 你摇滚!!!!!!!!!!!!我没有意识到您可以深入了解异常的堆栈跟踪。它发生在我使用的第三方库中,我只有编译好的 dll。不是源头。我想我能解决这个问题。
标签: c# winforms visual-studio-2010 nullreferenceexception