开发者

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);

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 FluentConfi开发者_开发百科guration();
        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?

I'm using NHibernate 3.1 and NHibernate validator 1.3


I haven't used nhibernate validator before but nHibernate needs a ProxyFactory class to be specified as part of the configuration other wise it throws this sort of error

I generally use the xml mapping files and config files this is the line that I would normally add <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>

Any of the proxy factories would do. it comes down to preference.


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

C# Uncaught exception in unit test

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜