2

I have a problem with third party libraries.

The main project using one of the third party library has a dependency; old version of NewtonSoft.

I've created a new project using another third party library also required NewtonSoft but newer version. I tested my functions and it works fine.

But once I call it in the main project, I got an errors

"Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0"

I cannot update the older version in the main project & it might have some conflicts.

How can I use 2 different versions of the same dll in the main project?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Nik D
  • 41
  • 4
  • Are we talking about multiple .EXEs in your solution? Otherwise you could use a separate AppDomain –  Jan 25 '16 at 05:37
  • How about using [`bindingRedirect`s](https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx) in your application's configuration file? – Uwe Keim Jan 25 '16 at 05:38
  • You might also handle the [`AppDomain.AssemblyResolve` event](https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve(v=vs.110).aspx). [See here for an example](http://www.aboutmycode.com/net-framework/assemblyresolve-event-tips/). – Uwe Keim Jan 25 '16 at 05:47
  • 2
    Exact same question regarding `Newtonsoft.Json.dll` http://stackoverflow.com/questions/15703991/use-different-versions-of-dll-file-in-one-app – Irshad Jan 25 '16 at 05:48
  • @Irshad, the answer in that question is specific only for if it's compatible to each other. – Nik D Jan 25 '16 at 06:04
  • 1
    @Uwe Keim, bindingRedirect doesn't work. I will check AppDomain. Thanks – Nik D Jan 25 '16 at 06:07
  • Please see the marked duplicate for a number of useful suggestions, including a lengthy discussion of some of the options. There is also an answer describing how to use `AssemblyResolve`, e.g. so you can specify different DLLs to load in different AppDomain, depending on the library that needs it. If the marked duplicate does not address your concern, please post a new question and this time provide more details, including a comprehensive explanation of what you've already tried and why that didn't work. Please also consider including a good [mcve] to show clearly the scenario at hand. – Peter Duniho Jan 25 '16 at 08:19

0 Answers0