休眠验证器 [英] Nhibernate Validator

查看:96
本文介绍了休眠验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在单元测试中,调试时出现错误.奇怪的是,每当我运行测试(仅在调试测试时),我都没有得到此信息.每当我尝试使用NHibernate Validator验证我的实体之一时,都会出现异常.以下行将引发以下异常.

In my unit tests I am getting an error when I am debugging. The weird thing is I do not get this whenever I just run the test (it's only when debugging a test). I get an exception whenever I try to validate one of my entities with NHibernate Validator. The following line throws the exception below.

InvalidValue[] invalidValues = validatorEngine.Validate(group);

异常:未配置ProxyFactoryFactory. 使用可用的NHibernate.ByteCode提供程序之一初始化会话工厂配置部分的'proxyfactory.factory_class'属性. 例子: NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu 例子: NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle

Exception: The ProxyFactoryFactory was not configured. Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers. Example: NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu Example: NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle

我正在这样配置验证器引擎:

I'm configuring the validator engine like this:

var nhvConfiguration = new FluentConfiguration();
        nhvConfiguration
           .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal)
           .Register(Assembly.Load("Business.Objects")
           .ValidationDefinitions());

        validatorEngine = new ValidatorEngine();
        validatorEngine.Configure(nhvConfiguration);

我不确定这是怎么回事.有人知道为什么我在调试时而不是仅在运行测试时收到此错误吗?

I'm not sure what's going on here. Anyone know why I am getting this error while debugging and not while just running the test?

我正在使用NHibernate 3.1和NHibernate验证器1.3

I'm using NHibernate 3.1 and NHibernate validator 1.3

推荐答案

引发此异常的原因与任何nhibernate配置无关.以下帖子解释了为什么我遇到此异常.

The reason it was throwing this exception was unrelated to any nhibernate configuration. The following post explains why I was getting this exception.

C#单元测试中未捕获的异常

这篇关于休眠验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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