簡體   English   中英

發生未處理的異常(運行已安裝的應用程序時)

[英]Unhandled exception has occurred (when running installed application)

我使用installshield來編譯在調試期間或使用VS編譯和發布時可以正常運行的應用程序。

運行安裝的應用程序時,出現以下錯誤信息: 例外

有關調用即時(JIT)調試而不是此對話框的詳細信息,請參見此消息的末尾。

**************異常文本************** System.ArgumentNullException:值不能為null。 參數名稱:System.IO.File.AppendAllText(String路徑,String內容)處的路徑,位於c:\\ Users \\ Jamie \\ Documents \\ SerialPortListener \\ SerialPortListener \\ MainForm.cs中的SerialPortListener.MainForm.MainForm_Load(對象發送方,EventArgs e)處: System.Windows.Forms.Form.OnLoad(EventArgs e)的第291行位於System.Windows.Forms.Control.CreateControl的System.Windows.Forms.Form.OnCreateControl()處(Boolean fIgnoreVisible)
在System.Windows.Forms.Control.WmShowWindow(Message&m)在System.Windows.Forms.Control.WndProc(System.Windows.Forms.ScrollableControl.WndProc) (消息&m)在System.Windows.Forms.ContainerControl.WndProc(消息&m)在System.Windows.Forms.Form.WmShowWindow(消息&m)在System.Windows.Forms.Form.WndProc(消息&m)在System.Windows System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message.m.System.Windows.Forms.Control.ControlNativeWindow.Onback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam) )

**************加載的程序集************** mscorlib程序集版本:4.0.0.0 Win32版本:4.0.30319.18444生成者:FX451RTMGDR代碼庫:文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll ---------------------------- ------------ SerialPortListener程序集版本:1.0.0.0 Win32版本:1.0.0.0代碼庫:file:/// C:/ Program%20Files%20(x86)/ P%26L%20Software / P%26L%20Hardware%20Helper / SerialPortListener / obj / x86 / Debug / SerialPortListener.exe ------------------------------- --------- System.Windows.Forms程序集版本:4.0.0.0 Win32版本:4.0.30319.18408構建於:FX451RTMGREL代碼庫:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/ System.Windows.Forms / v4.0_4.0.0.0__b77a5c561934e089 / System.Windows.Forms.dll ----------------------------- ----------- System.Drawing程序集版本:4.0.0.0 Win32版本:4.0.30319.18408內置人:FX451RTMGREL代碼庫:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/ System.Drawing中/ v4.0_4.0.0.0__b03f5f7f11d50a3a / System.Draw ing.dll ----------------------------------------系統組裝版本:4.0.0.0 Win32版本:4.0.30319.34238建於:FX452RTMGDR代碼庫:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ------- --------------------------------- System.Configuration程序集版本:4.0.0.0 Win32版本:4.0.30319.18408構建者:FX451RTMGREL代碼庫:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ----------- ----------------------------- System.Xml程序集版本:4.0.0.0 Win32版本:4.0.30319.34234構建於:FX452RTMGDR代碼庫:文件:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll --------------- -------------------------可訪問性程序集版本:4.0.0.0 Win32版本:4.0.30319.18408創建者:FX451RTMGREL

代碼庫:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

************** JIT調試**************要啟用即時(JIT)調試,請為此應用程序創建.config文件,或者計算機(machine.config)必須在system.windows.forms部分中設置了jitDebugging值。 還必須在啟用調試的情況下編譯應用程序。

例如:

啟用JIT調試后,任何未處理的異常都會發送到計算機上注冊的JIT調試器,而不是由此對話框處理。

我已經嘗試按照它說的那樣啟用jit調試。 那沒有用。 我似乎無法弄清楚這個問題的原因。 我在表單的關鍵點添加了一些代碼,以將行號寫入文本文件,這樣我就可以看到失敗的地方,但似乎錯誤發生在記錄這些消息之前。 如果單擊“繼續”,則消息將一直顯示,如果單擊“繼續”,則似乎在代碼中的執行速度確實很慢,但是需要多次單擊同一錯誤。

下面是MainForm_Load方法:

private void MainForm_Load(object sender, EventArgs e)
{
    backgroundWorker1.RunWorkerAsync(txtTerminal.Text);
    File.AppendAllText(ConfigurationManager.AppSettings["ErrorLog"],"Line:284" + Environment.NewLine);
}

您生成的路徑MainForm_Load的方法MainForm

失敗,結果變為null 至少那是例外的意思。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM