In my previous post I introduced Fluent NHibernate and NHibernate Burrow. If you have been trying the two together, you’ll have noticed that Burrow has been compiled against a lower version (2.0) of NHibernate than Fluent NHibernate has (which uses 2.1).

Trying to use Burrow with the newer version of NHibernate results in the following exception being thrown:

FileLoadException: Could not load file or assembly ‘NHibernate,
Version=, Culture=neutral, PublicKeyToken=aa95f207798dfdb4’
or one of its dependencies. The located assembly’s manifest definition
does not match the assembly reference. (Exception from HRESULT:

In order to solve this, you could go out and get the Burrow source code from here and compile your own version against NHibernate 2.1. But that’s a lot of work which should become obsolete when the next version of Burrow (or NHibernate) comes out. Instead, you can use assembly redirection.

In your web.config file, add the following:

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

And that’s all you need. Now, whenever some library (read: Burrow) asks for NHibernate 2.0, it’ll be redirected to NHibernate 2.1.

I hope this post was useful to you.


If you liked this post, please click on one of the advertisements below. Thanks!

17 Responses to “Making NHibernate Burrow work with NHibernate 2.1”

  1. 1 Robert Graves

    This solution got me most of the way there. I had to add two more binding redirections in my project (The last because I’m using .Net 3.5).

    Here are my additional binding redirections.

    However I still get an error due to what looks like a breaking change in NHibernate 2.1. The signiture for NHibernate.Engine.ISessionFactoryImplementor.GetEntityPersister(System.String, Boolean) is now NHibernate.Engine.ISessionFactoryImplementor.GetEntityPersister(System.String). Here’s the error:

    [MissingMethodException: Method not found: ‘NHibernate.Persister.Entity.IEntityPersister NHibernate.Engine.ISessionFactoryImplementor.GetEntityPersister(System.String, Boolean)’.]
    NHibernate.Burrow.Impl.PersistenceUnitRepo.GetPU(Type t) 0
    NHibernate.Burrow.Impl.AbstractConversation.GetSessionManager(Type t) 26
    NHibernate.Burrow.Impl.AbstractConversation.GetSession(Type entityType) 13
    NHibernate.Burrow.BurrowFramework.GetSession(Type entityType) 23
    NHibernate.Burrow.AppBlock.DAOBases.GenericDAO`1.get_Session() 36
    NHibernate.Burrow.AppBlock.DAOBases.GenericDAO`1.CreateCriteria() 20

  2. 2 Erik Burger

    Hi Robert,

    It seems that your post got a bit garbled. If you drop me a line at eburger at I can take a look and maybe help you out. I am using .Net 3.5 myself and the binding I described was all I needed. I’d love to help you figure out the rest.


  3. 3 Luca Del Tongo

    Thanks a lot for your last two posts,
    they are really valuable to keep all things updated 🙂

  4. 4 Erik Burger

    My pleasure Luca. It’s projects like Fluent and Burrow that make NHibernate a pleasure to use..imho far more than any other product I’ve seen. So anything I can do to help is my privilege 🙂


  5. 5 Luca Del Tongo

    Hi Erik… today i have tried to apply your suggestion in my current project and i receive the same error Robert encounter…
    so i have solved this problem simply by removing assembly redirection inside web.config and after having compiled only the main nhibernate burrrow project, i simply have referenced the new nhibernate.burrow assembly… to compile nhibernate burrow against the latest nh release as Robert suggested it’s necessary to remove a parameter from GetEntityPersister method…
    basically it works with the old school way 🙂

  6. 6 Erik Burger

    Hi Luca,

    I am glad you got it working though I am still stumped as to why it does work for me. Of course, the excuse “it works on my machine” totally doesn’t apply 😉 so I will look into it some more as soon as my calendar frees up a bit. If I find anything I’ll be sure to update my post.


  7. 7 David Carr

    Hi Erik,

    Just to confirm that there are a few breaking changes; one in the Burrow dll and three in Burrow.AppBlock dll (you may not use the latter).

    In Burrow:

    On line 51 of PersistenceUnitRepo.cs. Just remove the extra ‘false’ parameter on the method. The GetEntityPersister method seems to take only one argument in the 2.1 version of NHibernate.

    In Burrow.AppBlock:

    On line 63 of PaginableCriteria.cs change ‘cloned.Orders.Clear();’ to ‘cloned.ClearOrders();’

    On line 307 of GenericDAO.cs change ‘c.Orders.Clear();’ to ‘c.ClearOrders();’

    There’s also an interface (AbstractCriterion) which has been extended in the new NHibernate to include a GetProjections() method, so you need to add the extra method on EqOrNullExpression, which implements this.

    public override IProjection[] GetProjections()
    return null;

    If you have Visual Studio it’s pretty easy to download the source, change the reference to NHibernate to the newer version and recompile with the four changes.

    I hope this helps someone


  8. 8 Erik Burger

    Hi David,

    Thank you very much for your input! I am positive it will indeed help out some.



  9. 9 Kyle Koss

    Just thought I’d mention the problem I had when building Burrow against NHibernate 2.1. It seems that if you have Burrow configured to use more than one database it doesn’t work. I kept getting the ‘NHibernate.MappingException: No persister for: ‘ error, and I couldn’t figure out what I had done wrong. So, I downloaded NHibernate 2.0, and set it up with that, and it worked fine.

  10. 10 Jay Bohac

    Hey Erik,

    This page has been tremedously helpful (just started using nhibernate). I have an issue in my unit test teardown when i call the BurrowFramwork method CloseWorkspace and it just hangs and never finishes. Any Ideas? I can retrieve “A” object from a unit test just fine, but it hangs after retrieving “B” object. I’m using Nhibernate 2.1 with Fluent and Burrow. Thanks.


  11. 11 Erik Burger

    Hi Jay,

    I am not sure I understand your problem 100% but I do not use Burrow’s xxxWorkspace methods in my unit test code. In my setup I use new BurrowFramework().GetSession() to create a session, then in my teardown I use session.Close() and session.Dispose() to clean up. Perhaps using that method resolves your problem?


  12. 12 Jay Bohac

    Hey Erik,

    I ended up recompiling Burrow with the newer version of Nhibernate (2.1) and used the comments from David Carr, and it works fine now. Thanks for the info!


  13. 13 Erik Burger

    Hi Jay,

    No problem, you are very welcome.


  14. 14 sss

    For everyone interested, I have compiled Burrow for use with NHibernate using the instructions from David. You can download it here:

    It contains:


    I have also included NHibernate.JetDriver compiled against NHibernate Most people won’t need it, it’s a Driver for using NHibernate with Microsoft Access, but maybe someone will find it useful. If you don’t use Microsoft Access, delete this file.

    Remove all assembly redirects regarding NHibernate from your web.config / app.config file, you won’t need them any more with these dll files.

    For any questions email filzstiftegmxde

  15. 15 Erik Burger

    Thanks for that sss, that’s a great help!

  16. 16 Chris Yates

    I have verified that David Carr’s instructions work with NHibernate 3.0 Beta 1 as well. I also added a quick function to NHibernate.Burrow.AppBlock.DAOBases.GenericDAO to support Linq in 3.0. Here it is:

    public IQueryable Query()
    return Session.Query();

    So now you can do something like:

    User me = (from u in new GenericDAO().Query() where u.username == “cyates” select u).FirstOrDefault();

  17. 17 Erik Burger

    Excellent Chris thanks for the update!

Leave a Reply