views:

145

answers:

3

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.

+5  A: 

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>
Andrew Smith
Thank you very much :)
Pondidum
A: 

The latest versions, NHibernate.Validator 1.2.0 CR1 and FluentNHibernate 1.0.0.632, are both built against NHibernate 2.1.2.4000.

To get the latest version of FluentNHibernate, go to the build server at CodeBetter.com.

To get the latest version of NHibernate.Validator, go to NHForge.

Daniel Schilling
A: 

Not that it'll fix your problem, but have you considered FluentValidation. Still, sounds like you've got a reference somewhere that requests a specific version of the DLLs.

pms1969