1
我在i7 intel,Windows 7 Ultimate,VS2010 Ultimate中創建,構建和發佈應用程序。 在這臺機器上運行的應用程序使用代碼。在另一臺機器不工作,爲什麼。在此先感謝,ocaccy。C#應用程序發佈後不工作,爲什麼?
if(!Directory.Exists("C:\\users"))
{
DirectoryInfo di=Directory.CreateDirectory("C:\\users");
}
IniFile ini=new IniFile("C:\\users\\monitoring_config.ini");
Error Message on created machine:
************** Exception text **************
System.NullReferenceException: Object reference not set to an instance of an object.
Local MonitorX.CommPort.Open()
Local MonitorX.Monitor.checkConfigINI()
Local MonitorX.Monitor.btn_Preferences_Click(Object sender, EventArgs e)
Local System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
Local System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
Local System.Windows.Forms.Control.WndProc(Message& m)
Local System.Windows.Forms.ButtonBase.WndProc(Message& m)
Local System.Windows.Forms.Button.WndProc(Message& m)
Local System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)..........................................................
它似乎像錯誤是與'MonitorX.CommPort.Open()' – 2013-05-08 05:22:25
有關,它將有助於查看所有與該方法有關的代碼以及錯誤顯示如何定義'MonitorX',只是好奇如果您正在編寫C#爲什麼要使用IniFile這可以完成,但爲什麼不使用.net框架提供的內置配置文件..?System.NullReferenceException:未將對象引用設置爲對象的實例。 '意思是你正試圖使用和或者給一個對象指定一個值,但你沒有正確創建一個'新'' – MethodMan 2013-05-08 05:24:12
的實例謝謝。 非常大;可能會通過電子郵件? – 2013-05-08 06:38:31