0

Using Visual Studio 2015, I have built a solution with :

  • An ASP NET Web application with MVC 6 : the project uses Remotion.linq.dll version 2 because of Entity Framemork 7 dependency used for authentication.

  • Two Windows Class Library : 'Services' and 'Data'. Those two are referenced by the web application. Project Data uses NHibernate to access the data layer, which rely on Remotion.linq.dll version 1.

My problem is that when I launch my app, only one of the two versions is referenced, causing the application to crash.

My questions are :

  • Can we manage to reference two distincts versions of the DLL in my solution ?
  • If not, can we make NHibernate work with Remotion.linq.dll version 2 ?
Camille Laborde
  • 858
  • 11
  • 17

2 Answers2

1

Nope, side by side isn't supported. Don't do it.

davidfowl
  • 37,120
  • 7
  • 93
  • 103
0

You must try a binding redirect to see if you can keep only one assembly. About binding redirect you can read here: https://msdn.microsoft.com/en-us/library/2fc472t2(VS.80).aspx or search the stack for this particular keywords.

It really depends if there are same functionalities in the assemblies or there are different functionalities. There isn't a general answer.

If you really need to use two assemblies, here is your answer http://blogs.msdn.com/b/abhinaba/archive/2005/11/30/498278.aspx.

And PS: making NHibernate work with Remotion.linq.dll v2 looks like a big attempt for me (modifying dependencies and things like that).

UPDATE: CodeBase reference https://msdn.microsoft.com/en-us/library/efs781xb.aspx

There is another possibility to bind assembly versions. Copy in GAC and reference them by strong name (they must have one), but i didn't try that.

Razvan Dumitru
  • 11,815
  • 5
  • 34
  • 54
  • Those solutions only work when your project is referencing explicitly multiple version of a same DLL no ? In my case, it is my dependencies (NHibernate & Entity Framework) which references different versions of Remotion.Linq.dll – Camille Laborde May 26 '15 at 13:54
  • Oh i understand now. Sorry for misunderstanding. That's a good question. I don't know what's happening. Probably it won't work. If you give it a shot, please tell me the output. – Razvan Dumitru May 26 '15 at 15:14
  • As i see here: http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html is discribed as "hey, if anyone asks you to load any version of X that's less than 2.0.1.5, please go ahead and load 2.0.1.5 instead". So it might work. – Razvan Dumitru May 26 '15 at 15:17
  • And here is a link which discribes the nuget add-bindingredirect feature https://docs.nuget.org/consume/package-manager-console-powershell-reference – Razvan Dumitru May 26 '15 at 15:18
  • Thanks for the links ! We looked it carefully and added a binding redirection : now Nhibernate uses the Remotion.linq.dll v2, and as expected, it doesn't work well ^^ Maybe i misunderstand how to correctly use the binding : is there a way to bind each project to its proper Remotion.linq.dll version ? – Camille Laborde May 27 '15 at 08:12
  • As i said It really depends if there are same functionalities in the assemblies and so on. You can use a tag named codeBase and define dependencies like explained in http://stackoverflow.com/questions/2460542/using-different-versions-of-the-same-assembly-in-the-same-folder – Razvan Dumitru May 27 '15 at 09:33
  • I've updated my answer with codebase reference and another approach (not tested). – Razvan Dumitru May 27 '15 at 09:36