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

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

问题描述

我在调试调用另一个 AppDomain 的应用程序时遇到问题,因为如果在另一个 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.

我已经正确包装了在 try/catch 中引发的方法调用,并且在我正常运行应用程序(ASP.NET MVC 应用程序)时正确捕获了异常,但是在 Visual Studio 2010 中调试 w3wp.exe 时,它总是在抛出的方法调用上中断,即使它应该被捕获,我也无法绕过异常.

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.

我尝试装饰外部方法,其中 try/catch 和 throwing 方法调用是用 [DebuggerStepThrough] 完成的,但这绝对没有效果.执行Continue (F5)"、Step over (F10)"或Step Out (F11)"也没有任何作用;Visual Studio 只是暂停了一会儿,然后在完全相同的位置再次中断,出现完全相同的异常.一旦 Visual Studio 在发生异常的点停止,似乎绝对没有办法继续前进.

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.

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

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 跨越了本机/托管边界

FileNotFoundException crossed a native/managed boundary

我正在正确地捕获 FileNotFoundException 并且正如我所说的那样,它在运行应用程序时有效,但在调试时无效.如果 assembly.GetExportedTypes() 抛出,我怎样才能让调试器明白我会给老鼠屁股?

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?

我以为我通过取消选中 Visual Studio 2010 中名为当异常跨越 AppDomain 或托管/本机边界时中断(仅限托管)"的选项(在调试> 常规下)来解决这个问题,但问题刚刚再次出现.我已经将 [DebuggerStepThrough][DebuggerStepperBoundary][DebuggerNonUserCodeAttribute] 洒在有问题的方法上,但没有任何效果.

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.

推荐答案

Visual Studio 2010 中有一个选项叫做当异常跨越 AppDomain 或托管/本机边界时中断(仅限托管)"(在调试 > 常规下),当未经检查,有时会有所帮助.如果不需要退出 Visual Studio 2010,请删除所有临时文件,然后重试.不是一个非常优雅的解决方案,所以如果有人有更好的想法,请提供.

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天全站免登陆