Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

c# - System.ObjectDisposedException

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

Event Source: .NET Runtime 2.0 Error Reporting Event

Category: None

Event ID: 5000

Date: 30.10.2010

Time: 21:58:57

User: N/A

Computer: SERVER-PROD

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

ObjectDisposedException is:

The exception that is thrown when an operation is performed on a disposed object. (source)

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.

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. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...