年后第一问,.NET高手进来看

yuetoby 2006-02-05 08:19:36
程序运行一段时间后,发生自动退出情况。错误如下:
异常:Object reference not set to an instance of an object.
方法:TranslateMessage
堆栈: at System.Windows.Forms.UnsafeNativeMethods.TranslateMessage(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
模块中对frmMain调用ShowDialog。请高手指点,是不是frmMain里有问题,还是Framework有问题?
PS:有的时候DispatchMessageA方法也会引发错误。
...全文
238 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuetoby 2006-02-07
  • 打赏
  • 举报
回复
算了,重新做一个Main好了,谢谢大家,结贴
brando_beat 2006-02-07
  • 打赏
  • 举报
回复
jf
yuetoby 2006-02-06
  • 打赏
  • 举报
回复
我不会用内存地址访问对象.....
xgen007 2006-02-06
  • 打赏
  • 举报
回复
或者是你的showdialog中的某个参数是空值~~~
ChrisAK 2006-02-06
  • 打赏
  • 举报
回复
代码贴出来大家看下嘛~~
dwx1981426 2006-02-06
  • 打赏
  • 举报
回复
ChrisAK(Chris) 说的完全正确
jxufewbt 2006-02-06
  • 打赏
  • 举报
回复
断点调试跟踪一下
jjyjjyjjy 2006-02-06
  • 打赏
  • 举报
回复
对象没有初始化
lidong6 2006-02-05
  • 打赏
  • 举报
回复
你的frmMain里的构造函数及LOAD事件里都有什么代码?
代码蜗牛sky 2006-02-05
  • 打赏
  • 举报
回复
我认为不关线程的事,你是不是使用了内存地址来访问对象啊?

GC执行回收的时候会移动堆内对象的
califord 2006-02-05
  • 打赏
  • 举报
回复
对不起,帮不了你
yuetoby 2006-02-05
  • 打赏
  • 举报
回复
认为是线程有问题的举手
lvw8000 2006-02-05
  • 打赏
  • 举报
回复
好像是你对不存在的对象赋值了
hedongfu 2006-02-05
  • 打赏
  • 举报
回复
你这个错误信息看不出来问题,能不能再详细点
mmcl 2006-02-05
  • 打赏
  • 举报
回复
把具体出错代码贴出来
ChrisAK 2006-02-05
  • 打赏
  • 举报
回复
Object reference not set to an instance of an object.
-----------------------------
对对象的引用未设置到对象的实例.你是不是有哪个变量未初始化就用了?或者用了已经销毁了的对象?

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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