在单元测试C#uncaught异常

编程入门 行业动态 更新时间:2024-10-25 14:34:37
本文介绍了在单元测试C#uncaught异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我现在遇到一个很奇怪的问题,在调试一个单元测试。如果我调试单元测试(Ctrl + R键Ctrl + T键),我得到一个未捕获的异常。如果我只是运行单元测试(CTRL + RT)我不明白此异常。

I'm encountering a very strange issue while debugging a unit test. If I debug the unit test (ctrl+r ctrl+t) I am getting an uncaught exception. If I just run the unit test (ctrl+r t) I do not get this exception.

未捕获的异常是一个 NHibernate.ByteCode.ProxyFactoryFactoryNotConfiguredException。

堆栈跟踪:

at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Bytecode\AbstractBytecodeProvider.cs:line 32 at NHibernate.Validator.Util.NHibernateHelper.IsProxyFactoryConfigurated()

我用反射来看看定义此方法(NHibernate.Validator大会。 ..它是开源的),这里是抛出异常的方法:

I used .Net Reflector to look at the assembly that defines this method (NHibernate.Validator ... it's open source) and here is the method that "throws" the exception:

public static bool IsProxyFactoryConfigurated() { try { IProxyFactoryFactory proxyFactoryFactory = Environment.BytecodeProvider.ProxyFactoryFactory; return true; } catch (ProxyFactoryFactoryNotConfiguredException) { return false; } }

这怎么能例外不会被捕获的尝试捕捉阻止?

How can this exception not be caught by that Try Catch block?

推荐答案

这听起来像你看到的第一次机会异常。

你有破第一次机会异常启用?您应该能够配置它在调试 - >例外菜单。

Do you have "Break on first-chance exceptions" enabled? You should be able to configure it in the Debug->Exceptions menu.

更多推荐

在单元测试C#uncaught异常

本文发布于:2023-10-31 05:07:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545093.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   异常   uncaught

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!