How best to handle multiple versions of the same dependency?

Matthew Lyons 1 Reputation point
2021-03-15T23:16:13.96+00:00

Hello everyone!

I have two dependencies that my program is using that themselves rely on different versions of the same dependency (Newtonsoft.Json.dll).

How do I handle having multiple versions of the same dependency in my program? Not having the correct version means that one of my dependencies or the other now isn't going to work. And hoping to align the two dependencies without considering future development and updates would be a nightmare...

I figured this has to be something that everyone deals with from time to time, but it's the first time I'm running into it. What does everyone else do in this instance? Can you place dependencies in separate folders in the install directory somehow?

I appreciate everyone's help!

Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,861 Reputation points
    2021-03-16T01:02:17.69+00:00

    You can use a binding redirect in the config file to tell the program to use the one version of newtonsoft.json.dll.

    https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.