System.ObjectDisposedException

后端 未结 2 1307
南方客
南方客 2020-12-06 10:24

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

相关标签:
2条回答
  • 2020-12-06 10:54

    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.

    0 讨论(0)
  • 2020-12-06 10:54

    Something is accessing an object that has been disposed. Often this can happen if you have multi-threading on a form. You start the backgroundworker/thread/timer, and then dispose the form. When the backgroundworker/thread/timer tries to update the form in some way, you get this exception.

    0 讨论(0)
提交回复
热议问题