4

I have a project where I would want to use some specific version of a dll.

The GAC contains couple of versions of that dll (new & old), I would want to use the old when running the program.

Issue is that the newest dll is always picked-up from the GAC.

Would you know if there is a way to either:

  • Force the usage the dll that is in the run folder (the one I'm referencing in my solution, working fine in debug).
  • Force the usage of the old version of the dll from the GAC.

Thank you!

2
  • First search brought me here. stackoverflow.com/questions/892073/… Commented Aug 5, 2014 at 5:43
  • 1
    thanks but I don't own the dll I'm using Commented Aug 5, 2014 at 5:46

3 Answers 3

1

You can use a binding redirect in your app.config or web.config in the runtime node:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> </appSettings> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 

Make sure you have the correct publicKeyToken and know which versions you want to redirect to what version.

(You can check a publicKeyToken of a DLL like this with this info.)

MSDN Documentation

You can also generate these for an entire solution using the Package Manager Console

Get-Project -All | Add-BindingRedirect 

This will update all app.config files and add the binding redirect.

Sign up to request clarification or add additional context in comments.

Comments

0

When you have added the library to your project and you collapse the 'References'-node of the project tree, you'll see the added library. When you select it and click the 'Properties'-node of the context menu, you can specify if a specific version of the library should be used and which version to use. Simply set 'Specific Version' to true and specify the Version number. Then you don't have to cope with the question where the version you want is loaded from.

2 Comments

Hi Matten. Thanks for your answer, but given what I can read here and my tests, this seems to be only for compile time, not run time: stackoverflow.com/questions/1232842/…
Yes, this is only at compile time.
0

Have you try to "Redirecting Assembly Versions" in your app.config? http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.