ILearnable .Net

August 27, 2010

Running two versions of NHibernate side by side

Filed under: Uncategorized — andreakn @ 08:33
Tags: , , ,

In my current project we had used NHibernate/Fluent NHibernate (version 2.1.2.4000) for some custom data access for data which shouldn’t live in the EPiServer DB.

Then suddenly we started to integrate EPiServer Community 3.2 (EPiServer Relate + v1.0.1.0) into our solution and stumbled a bit on the fact that it used a different version of NHibernate (version 1.2.0.4000 to be exact)

on the verge of giving up and rewriting our custom data access to raw ADO.net I stumbled upon the solution: using assemblyBinding to instruct .Net *where* to look for the different versions of the dlls. Here’s a snippet from web.config:

<configuration>
   ...
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
        <codeBase version="1.0.0.3" href="dlllib\nhibernate1.2\Iesi.Collections.dll" />
        <codeBase version="2.1.2.4000" href="dlllib\nhibernate2.1\Iesi.Collections.dll" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
        <codeBase version="1.2.0.4000" href="dlllib\nhibernate1.2\NHibernate.dll" />
        <codeBase version="2.1.2.4000" href="dlllib\nhibernate2.1\NHibernate.dll" />
      </dependentAssembly>
      ...
     </assemblyBinding>
  </runtime>
</configuration>

So what I did was to have a folder structure like this

– site
– – bin
– – dlllib
– – – nhibernate1.2
– – – – Nhibernate.dll (v1.2.0.4000)
– – – – Iesi.Collections.dll (v1.0.0.3)
– – – nhibernate2.1
– – – – Nhibernate.dll (v2.1.2.4000)
– – – – Iesi.Collections.dll (v2.1.2.4000)

So there it is, no more headscratching when different versions of the same dlls are needed. “codeBase” to the rescue!

Advertisements

1 Comment »

  1. […] posted here: Running two versions of NHibernate side by side This entry was posted in EPiServer articles and tagged current, current-project, custom, […]

    Pingback by Running two versions of NHibernate side by side | EPiServerCMS — September 30, 2010 @ 00:45 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: