nhibernatefluent-nhibernatenhibernate-validator

fluentnhibernate and nhibernate validator version error


We have a project using FluentNibernate to map the entities. Now I need to add some format validation to these maps. For Nullable, Length and such we are currently using the mappings. I added NHibernate Validator to the project, but received a compile time error about needing NHibernate version 2.1.2.4000. So I upgraded to that version just to get a run-time error stating that it could not find NHibernate 2.1.0.4000. Could I write extension methods to do the validation using FluentNibernate? Do I have to recompile both using the same version of NHibernate? The preferred method would be to use a release of these. Any other device would appreciated.


Solution

  • 1) Recompiling is an option, this would allow you to use both of these without the assembly problems.

    2) Another would be an assembly binding redirect, any calls to an earlier version of NHibernate you can force to go to the version that you have. You can do this with your app.conifg / web.conifg

    (you can find more about it here)

    <configuration>
           <runtime>
              <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                 <dependentAssembly>
                    <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4"/>
                    <bindingRedirect oldVersion="2.1.0.4000" newVersion="2.1.2.4000"/>
                 </dependentAssembly>
              </assemblyBinding>
           </runtime>
    </configuration>