title: NullReferenceException at Application.Run(new Main())
body: <p>I am at my wit’s end. I have an application that likes to crash a few minutes into running with a <code>NullReferenceException</code> (Object reference not set to an instance of an object). Normally I could deal with that just fine, but when Visual Studio breaks out, it’s telling me the issue is happening at <code>Application.Run(new Main());</code>. I have no idea what to do to begin trouble shooting this. The Call Stack doesn’t help any because it just points to that <code>Application.Run(new Main());</code> line.</p>
  
  <p>I went into the Exception window of Visual Studio (<code>CTRL + ALT + E</code>) and told it to report ALL exceptions to me. I was hoping it would find the issue before I get this <code>NullReferenceException</code>. But no luck.</p>
  
  <p>What tools are available to me to help find this issue?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is the Call Stack as reported by Visual Studio:</p>
  
  <pre><code>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&amp; m)
         at System.Windows.Forms.Control.WndProc(Message&amp; m)
         at System.Windows.Forms.ScrollableControl.WndProc(Message&amp; m)
         at System.Windows.Forms.UserControl.WndProc(Message&amp; m)
         at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
         at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
         at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
         at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; 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()
  </code></pre>