title: Unhandled exception has occurred (when running installed application)
body: <p>I use installshield to compile an application which works fine during debugging, or when compiled and published using VS.</p>
  
  <p>When I run the installed application I get the following error message:
  <img src="https://i.stack.imgur.com/DHn3j.png" alt="exception"></p>
  
  <blockquote>
    <p>See the end of this message for details on invoking  just-in-time
    (JIT) debugging instead of this dialog box.</p>
    
    <p>************** Exception Text ************** System.ArgumentNullException: Value cannot be null. Parameter name:
    path    at System.IO.File.AppendAllText(String path, String contents) 
    at SerialPortListener.MainForm.MainForm_Load(Object sender, EventArgs
    e) in
    c:\Users\Jamie\Documents\SerialPortListener\SerialPortListener\MainForm.cs:line
    291    at System.Windows.Forms.Form.OnLoad(EventArgs e)    at
    System.Windows.Forms.Form.OnCreateControl()    at
    System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)<br>
    at System.Windows.Forms.Control.CreateControl()    at
    System.Windows.Forms.Control.WmShowWindow(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.ContainerControl.WndProc(Message&amp; m)    at
    System.Windows.Forms.Form.WmShowWindow(Message&amp; m)    at
    System.Windows.Forms.Form.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.Callback(IntPtr hWnd, Int32
    msg, IntPtr wparam, IntPtr lparam)</p>
    
    <p>************** Loaded Assemblies ************** mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.18444 built by: FX451RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ---------------------------------------- SerialPortListener
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Program%20Files%20(x86)/P%26L%20Software/P%26L%20Hardware%20Helper/SerialPortListener/obj/x86/Debug/SerialPortListener.exe
    ---------------------------------------- System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ---------------------------------------- System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ---------------------------------------- System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34238 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ---------------------------------------- System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ---------------------------------------- System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.34234 built by: FX452RTMGDR
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ---------------------------------------- Accessibility
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL</p>
    
    <h2>    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll</h2>
    
    <p>************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer
    (machine.config) must have the jitDebugging value set in the
    system.windows.forms section. The application must also be compiled
    with debugging enabled.</p>
    
    <p>For example:</p>
    
    <p>
         </p>
    
    <p>When JIT debugging is enabled, any unhandled exception will be sent to
    the JIT debugger registered on the computer rather than be handled by
    this dialog box.</p>
  </blockquote>
  
  <p>I have tried doing as it said and enabling jit debugging. That didn't work though. I can't seem to figure out the cause of this problem. I added some code at key points in the form to write the line number to a text file so I could see where it fails but it seems like the error occurs much before those logged messages. If I click continue the message keeps displaying, if I keep clicking, it seems as though it does slowly progress through the code but it takes many clicks of the same error.</p>
  
  <p>Below is the MainForm_Load method:</p>
  
  <pre><code>private void MainForm_Load(object sender, EventArgs e)
  {
      backgroundWorker1.RunWorkerAsync(txtTerminal.Text);
      File.AppendAllText(ConfigurationManager.AppSettings["ErrorLog"],"Line:284" + Environment.NewLine);
  }
  </code></pre>