在Visual Studio 2010中调试时,忽略跨AppDomains的异常 [英] Ignore exceptions that cross AppDomains when debugging in Visual Studio 2010

查看:315
本文介绍了在Visual Studio 2010中调试时,忽略跨AppDomains的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调试一个应用程序调用另一个AppDomain时遇到问题,因为如果其他AppDomain正在执行任何异常,异常就会起起来,导致Visual Studio 2010无论什么都会中断。



我正确地将方法调用包含在 try / catch 中,并且当我'通常运行应用程序(ASP.NET MVC应用程序),但是当在Visual Studio 2010中调试 w3wp.exe 时,它总是在抛出的方法调用中断开,没有我可以通过这个方法来解决异常,即使它被捕获。



我试图装饰外部方法,其中 try / catch 并且使用 [DebuggerStepThrough] 完成抛出方法调用,但这绝对没有影响。执行继续(F5),逐步(F10)或步出(F11)也不会; Visual Studio只是暂停一会儿,然后在完全相同的地方再次打破完全相同的例外。一旦Visual Studio停止在发生异常的时候,似乎绝对没有办法继续前进。



正在正在调用 assembly.GetExportedTypes()如果导出的类型引用了一个无法找到的程序集(我想忽略的情况),则可能会抛出。抛出的异常是:


FileNotFoundException越过本机/管理边界


正如我所说,我正在捕捉 FileNotFoundException ,这在运行应用程序时起作用,但在调试时不起作用。如果 assembly.GetExportedTypes() throws?如何使调试器了解我给老鼠屁股?



更新:



我以为我已经取消选中Visual Studio 2010中的选项,称为异常跨越AppDomain或受管理/本机边界(仅管理)时破坏)调试>常规),但是问题刚刚出现了。我已经撒了 [DebuggerStepThrough] [DebuggerStepperBoundary] [DebuggerNonUserCodeAttribute] 在有问题的方法上没有任何影响。

解决方案

Visual Studio 2010中有一个选项叫做异常时中断交叉AppDomain或管理/本机边界(仅管理)(在调试>常规)下,当未选中时,有时会有帮助。当我不需要退出Visual Studio 2010时,删除所有临时文件,然后重试。不是一个非常优雅的解决方案,所以如果有任何更好的想法,请提供他们。


I'm having problems with debugging an application that calls out to another AppDomain, because if an exception occurs in whatever the other AppDomain is doing, the exception bubbles up and causes Visual Studio 2010 to break no matter what.

I've properly wrapped the method call that throws in a try/catch, and the exception is properly caught when I'm running the application (an ASP.NET MVC application) normally, but when debugging w3wp.exe in Visual Studio 2010, it always breaks on the method call that throws and there's no way I can get past the exception even though it should be caught.

I've tried to decorate the outer method in which the try/catch and throwing method call is done with [DebuggerStepThrough] but that has absolutely no effect. Doing "Continue (F5)", "Step over (F10)" or "Step Out (F11)" does nothing either; Visual Studio just pauses for a bit and then breaks again at the exact same spot with the exact same exception. Once Visual Studio has stopped at the point in which the exception occurs, there seems to be absolutely no way to move on.

What I'm doing exactly is calling assembly.GetExportedTypes() which may throw if an exported type is referencing an assembly that can't be found (a circumstance I want to ignore). The exception thrown is:

FileNotFoundException crossed a native/managed boundary

I'm catching FileNotFoundException properly and as I've said, that works when running the application, but not while debugging. How can I make the debugger understand that I give a rats ass if assembly.GetExportedTypes() throws?

Update:

I thought I had this wrapped up by unchecking the option in Visual Studio 2010 called "Break when exceptions cross AppDomain or managed/native boundaries (Managed only)" (under Debugging > General), but the problem popped up again just now. I've sprinkled [DebuggerStepThrough], [DebuggerStepperBoundary] and [DebuggerNonUserCodeAttribute] on the method in question withuot any effect.

解决方案

There's an option in Visual Studio 2010 called "Break when exceptions cross AppDomain or managed/native boundaries (Managed only)" (under Debugging > General) that, when unchecked, sometimes helps. When it doesn't I need to quit Visual Studio 2010, delete all temporary files, and then try again. Not a very elegant solution, so if anyone have any better ideas, please provide them.

这篇关于在Visual Studio 2010中调试时,忽略跨AppDomains的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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