简体   繁体   English

程序崩溃与System.ObjectDisposedException

[英]Program crash with System.ObjectDisposedException

I'm having a weird problem with my program. 我的程序遇到了一个奇怪的问题。 I'm developing a windows form application. 我正在开发一个Windows窗体应用程序。 When I debug it through Visual Studio (F5) it works perfectly correctly, but when I run its executable it crashes and gives me "An unhandled exception of type 'System.ObjectDisposedException' occurred in mscorlib.dll". 当我通过Visual Studio(F5)进行调试时,它可以正常工作,但是当我运行它的可执行文件时它会崩溃并给我“mscorlib.dll中发生了'System.ObjectDisposedException'类型的未处理异常”。

I tried to put a top level (on my outermost function) try/catch for catching this exception, but still the program crashes. 我尝试将顶级(在我的最外层函数上)try / catch用于捕获此异常,但程序仍然崩溃。 What am I missing here? 我在这里错过了什么?

I didn't upload the code because I had to upload the whole code for you to see where the problem is. 我没有上传代码,因为我必须上传整个代码,以便查看问题所在。

If you can get the stack trace of the exception, it should help you debug the root cause. 如果您可以获得异常的堆栈跟踪,它应该可以帮助您调试根本原因。 You may find the Call Stack window helpful for this. 您可能会发现“调用堆栈”窗口对此有用。 Check out the instructions here: 看看这里的说明:

You may also want to disable the "Just My Code" option for debugging in Visual Studio. 您可能还想在Visual Studio中禁用“Just My Code”选项以进行调试。 This may give you better exception debugging information. 这可能会为您提供更好的异常调试信息。 Follow the instructions (to disable ) here: 按照说明( 禁用 )在这里:

Wow, an ObjectDisposedException that isn't caught by a top-level catch block? 哇,一个没有被顶级catch块捕获的ObjectDisposedException?

I'm not sure what I would do in this case - obviously, you want to see the stack trace and find out just what it is that was disposed. 我不确定在这种情况下我会做什么 - 显然,你想看到堆栈跟踪并找出它被处理掉的是什么。 There are a few un-catch-able exceptions, but this one isn't one of them. 有一些不可捕获的例外,但这个例子不是其中之一。 I'd probably attach a handler to the AppDomain.UnhandledException event, and see if that found anything. 我可能会将一个处理程序附加到AppDomain.UnhandledException事件,并查看是否找到了任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM