vs2010写的winform程序可以正常运行,做成setup安装后,在启动和关闭程序时。。。出现《未将对象引用设置到对象的实例》异常,怎么破

黎大 2016-11-30 02:02:37


如题,写了一个winform应用程序,在vs中启动、调试都没有问题,可是当我将这个程序做成setup安装包,并安装后,运行之出现异常,查看详情解释如下:


有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
在 ImageView.FormMain.Form1_Load(Object sender, EventArgs e)
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


忽略该异常后,程序可以正常运行,但是当我关闭程序的时候,又出现类似的异常
详情如下


有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
在 ImageView.FormMain.FormMain_FormClosing(Object sender, FormClosingEventArgs e)
在 System.Windows.Forms.Form.OnFormClosing(FormClosingEventArgs e)
在 System.Windows.Forms.Form.WmClose(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



求各路大神指点迷津,如果解决这个问题,看上去太恶心了。
...全文
428 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
黎大 2017-01-02
  • 打赏
  • 举报
回复
你们都是好人,谢谢,问题找到了,权限!!!!!win7的问题,对权限的控制。 调整项目属性,设置bin可以以管理员身份运行,就可以了!!!!!先要选clickonce,复选了然后再改回,就好了。
  • 打赏
  • 举报
回复
一个产品发布前,经过了几十万次测试运行,几百个(正规商用软件应该有上千个)测试用例进行顺序和并发多线程的反复测试。 出了问题以后,程序员绝不会说“我调试了”。
  • 打赏
  • 举报
回复
所谓“调试”,只是“点点点”鼠标之类的临时操作而已。 真正的质量来自于测试。如果分不清楚测试和调试概念的区别,自然还只是刚学编程的学生。编程的目的是为了通过测试,而测试的目的才是为了发布。编程是最低级的工作,并不能直接用来发布。你如果没有测试习惯,那么你的程序肯定是千疮百孔的。你如果会测试,那么在发布之后遇到了问题时,你也就会去研究实际运行的状态,来增加测试用例,或者调整系统日志。 所谓的“破”不是雷人噱头,是学习更加专业的开发和测试方法。
江湖评谈 2016-12-10
  • 打赏
  • 举报
回复
你要release而不是debugu
sinat_18863633 2016-12-09
  • 打赏
  • 举报
回复
这个你调试一边看哪边的少了个NEW
Silentdoer 2016-12-05
  • 打赏
  • 举报
回复
你有没有用Applcation.Close();或Environment.Close()函数?我以前也出现过类似的错误,最终是修改这些改好了,但具体是怎么弄好的不记得了。

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧