Search code examples
nhibernatenhibernate-validator

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 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?

I'm using NHibernate 3.1 and NHibernate validator 1.3


Solution

  • 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