title: UnhandledException - How to know what control made the application crash
body: <p>I have already delivered my app to customers but they are complaining that sometimes the app crashes, and they need to relaunch it.</p>
  
  <p>I told them to describe what they were doing and what option / window they were using when the app crashed, unfortunately none of them was able to say something. So I decided to make a <code>Global UnhandledException</code> function.</p>
  
  <p>I updated the app with below <code>Global UnhandledException</code> code and I'm receiving the error messages through email but my concern now is that I'm not going to be able to locate what control caused that error in order to fix the problem.</p>
  
  <p>So far, the error message I receive from 4 clients is <code>Index was outside the bounds of the array.</code> and I'm able to fix that but I'm not sure what VB control causes the problem as the app has many ListBoxes on each Window, and different controls.</p>
  
  <p>I just want to know whether there's a way to locate via <code>(e.Exception.[control name])</code> the exact control that raises the error.</p>
  
  <p>Below is my Global UnhandledException code</p>
  
  <pre><code>Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
      Try
          errorMsg = e.Exception.Message     'Store the error message in order to be sent via email to Support/Fix Departement via email
  
          e.ExitApplication = False
  
          thread = New System.Threading.Thread(AddressOf sendGlobalExcept)
          thread.Start()
      Catch
  
      End Try
  End Sub
  </code></pre>