2013-05-08 96 views
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).......................................................... 
+0

它似乎像錯誤是與'MonitorX.CommPort.Open()' – 2013-05-08 05:22:25

+0

有關,它將有助於查看所有與該方法有關的代碼以及錯誤顯示如何定義'MonitorX',只是好奇如果您正在編寫C#爲什麼要使用IniFile這可以完成,但爲什麼不使用.net框架提供的內置配置文件..?System.NullReferenceException:未將對象引用設置爲對象的實例。 '意思是你正試圖使用​​和或者給一個對象指定一個值,但你沒有正確創建一個'新'' – MethodMan 2013-05-08 05:24:12

+0

的實例謝謝。 非常大;可能會通過電子郵件? – 2013-05-08 06:38:31

回答

1

也許你不能用C寫的:\或C:\用戶。

1

也許您指向的文件丟失。如果不是,則可能缺少該文件的條目。

希望我可以幫助你有點

相關問題