System.ObjectDisposedException [英] System.ObjectDisposedException

查看:184
本文介绍了System.ObjectDisposedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行某些Windows应用程序,它已经运行了几天,然后继续正常运行。现在,我在事件查看器中发现了此错误。也许有人知道什么会导致此错误?

I am running some windows application and it's working for few days then stop working with no error. Now i found in event viewer this error. Maybe anyone have any idea what can cause this error?


事件类型:错误

Event Type: Error

事件源:.NET运行时2.0错误报告事件

Event Source: .NET Runtime 2.0 Error Reporting Event

类别:无

事件ID:5000

日期:30.10.2010

Date: 30.10.2010

时间:21:58:57

Time: 21:58:57

用户:N / A

计算机:SERVER-PROD

Computer: SERVER-PROD

描述:EventType
clr20r3,P1 program.exe,P2
1.0.0.0,P3 4cca7ed1,P4 mscorlib,P5 2.0.0.0,P6 4be90358,P7 1164, P8 0,P9 system.objectdisposedexception,P10
NIL。

Description: EventType clr20r3, P1 program.exe, P2 1.0.0.0, P3 4cca7ed1, P4 mscorlib, P5 2.0.0.0, P6 4be90358, P7 1164, P8 0, P9 system.objectdisposedexception, P10 NIL.


推荐答案

ObjectDisposedException是:

ObjectDisposedException is:


对已处置对象执行操作时抛出的异常。 (

换句话说,如果处置了实现IDisposable接口的类的实例-通过调用 Dispose()显式地隐式地(例如,如果它出现在 using 语句中或其他方式)–任何在对象上调用方法的尝试都会引发上述异常。

In other words, if an instance of a class that implements the IDisposable interface is disposed -- either explicitly by a call to Dispose() or implicitly, such as if it appears in a using statement or otherwise -- any attempts to call methods on the object will raise the exception above.

与大多数调试问题一样,如果不查看代码并在调试器中运行它,很难说出是什么原因造成的。您说程序运行了几天后,由于ObjectDisposedException崩溃。以我的经验,这通常意味着两件事之一:

As with most debugging problems, it's very difficult to say what is causing yours without actually looking at the code and running it in a debugger. You say that the program crashes with ObjectDisposedException after running for a few days. In my experience, this is usually means one of two things:


  1. 有一些非常不寻常的代码路径,如果采用,通常会导致崩溃

  2. 程序中的线程之间存在竞争条件。因此,崩溃看起来无法预测,并且可能难以重现

  1. There is some very unusual code path which, when taken, always causes a crash
  2. A race condition exists between threads in your program. Thus, the crash appears unpredictably and may be difficult to reproduce

我的建议是在调试器中启动程序,然后离开它运行直到抛出异常为止。然后,您可以返回此处,向我们提供相关代码,堆栈跟踪,调试输出等。

My advice to you is to start the program in the debugger, and leave it running until the exception is thrown. Then you can come back here and provide us with the relevant code, stack trace, debug output, etc.

这篇关于System.ObjectDisposedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆