在单元测试C#uncaught异常 [英] C# Uncaught exception in unit test

查看:163
本文介绍了在单元测试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()

我用.net反射来看看定义此方法(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异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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