【发布时间】:2013-05-02 05:42:05
【问题描述】:
我在 i7 intel、Windows 7 Ultimate、VS2010 Ultimate 中创建、构建和发布应用程序。 在这台机器上运行的应用程序使用代码。在另一台机器上不工作,为什么。提前感谢,ocaccy。
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()相关联 -
这将有助于查看与该方法相关的所有代码以及错误显示如何定义
MonitorX,只是好奇您是否正在编写 C# 为什么要使用 IniFile 这可以是完成但为什么不使用 .net 框架提供的内置配置文件..?System.NullReferenceException:对象引用未设置为对象的实例。Means you are trying to use and or Assign a value to an Object that you have not properly created anew`实例 -
谢谢。很大;可能是电子邮件?
-
在创建和发布应用程序的电脑中;问题结束了。 CommPort 为空!现在在另一台 W7 电脑上安装此应用程序,但无法运行,为什么?
-
我发现允许部分问题写入文件夹 C:\Users。将代码更改为在另一个地方编写并运行。
标签: c# winforms visual-studio-2010 windows-7 windows-xp