开发者

Tips for fixing dll version problems in .NET

I've just got to grips with the basics of NHibernate, and while refactoring my data access and domain layers I thought I might as well get cute and start using dependency injection for the data access layer. Unit testing here we come!

I thought since NHibernate开发者_如何学C uses loads of Castle dlls I might as well use Castle Windsor for the DI container. Just as I was firing up the app to see if it all worked, I got a dll reference issue.

Since I'm using NHibernate 2.1.2.4000, I already have a reference to Castle.Core 1.1.0.0. However, the version of Castle Windsor dll I am using (2.1.0.0) is telling it wants Castle.Core 1.2.0.0.

I'm kind of new to this crazy open-source class library malarkey. In general, how do I find out what the dll dependencies are for something in advance, and how do I find the version of Castle.Windsor which uses Castle.Core 1.1.0.0, which is the one I already have?

Alternatively, how do I find out if NHibernate will work with Castle.Core 1.2.0.0, or if it will break??

Thanks for your help.

David


There is a new open source project, Refix, that has been created to help with this very issue.

It helps in several ways:

  • It "reflects" over all the projects in your solution to work out if there is a common set of depenencies that can be "agreed on" by all projects. If so, it can update your project files accordingly.

  • If not, but certain versions of dlls are compatible with other versions, it can automatically update your config files with the appropriate assembly redirects.

  • It also acts as a central repository for all your various assemblies and their versions.

This project is new and in alpha only, but it certainly is functional and definitely worth a look. Additionally, the author (who I know personally) is very keen to get feedback and ideas on the project.

This is well worth a look IMHO.


A short term solution is using Assembly Binding Redirection.

A better alternative is compiling NHibernate from source using the Castle version you want.


I don't thing that NH could reference Castle.Core, you rather have the opposite situation: Active record which is part of castle project needs that version of NH. To make references consistent you can try to download all assemblies from castle family to have them matching the newest (Windsor in your case). That will require some regression testing and possible build issues. Alternatively you can recompile Windsor without requirement of specific Castle.Core version, but given such a big version difference you will probably face multiple compatibility issues or even build problems due to API change.


Well... you can deal with the version issues... or you could install them all in the GAC and stop worrying about it.

That makes for a less portable install process, but should do the trick.


This may be possible using an assembly binding redirection; see here for details.


Well apparently there's nothing certain you can do about it, so I've switched NHibernate to use Linfu instead of Castle for dynamic proxies and now I'm free to have a more up to date version of Castle.Core in my solution.

[Edit: there are responses that I hadn't seen when I added this, which may fix the problem also.]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜