Question: I do not understand the following problem I am facing.

I have 3 projects, A, B and C. All of them have a reference to `Newtonsoft.Json`, version `12.0.1`

Project a has a reference to both projects B and C. Project B, has a references to `Microsoft.IdentityModel.Tokens.Jwt`

When I run project A, I get the following runtime error when trying to execute the function necessary for creating my token.

**Message:**

> 
> "The type initializer for 'System.IdentityModel.Tokens.Jwt.JsonExtensions' threw an exception."
> 
> 
> 

**Inner Exception:**

> 
> "Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified."
> 
> 
> 

I have verified that all projects reference the same `Newtonsoft.Json` package with version `12.0.1`.
I have also checked my project files, to make sure there is no reference to `Newtonsoft.Json` version `10.0.0.0`

What am I missing?

Answer: 
Newtonsoft Json while useful is the source of many issues.

You will need to check all the NuGet packages referenced by every project in your solution to see what version of Newtonsoft Json they require. Some specify a minimal version, in which case you don't have an issue ( like > 10, anything higher than 10 will work ), others require a certain, fixed version ( = 10, must be 10, not less, not higher). This is up to the author of that particular NuGet package.

When you hit build, the dlls required by the referenced packages will be copied over, then the dlls required by any referenced projects will copied over and it is possible a certain version will be copied over and when you run your application, you get the error you have seen.

You can check this by looking in the bin folder of your build profile, right click the dll file and inspect its version to see what you have. Assembly redirection should help, when done in the right place, but there is an alternative solution, although it's not always possible.

If you can drop the Newtonsoft Json to the minimum version which satisfies all requirements then that is a good way to solve the problem. Chances are you don't need version 12, depending on what you are using from it and depending on what other packages require. You might be able to change all projects to reference the lower version without any side effects. If you can, you're golden, just make sure you don't upgrade by mistake. If not, you'll have to do the version redirecting like indicated in other answers.

The basic idea is to make sure, that in your solution, you only use one version of Newtonsoft. you can check this package at solution level, there is a consolidate option as well. 

So, check all projects in the solution, make sure they all use one version of Newtonsoft and that version is the same across all of them.

Once you manage to get everything on one level make sure that:

1. you delete the Temporary ASp.Net folder contents, in Windows / Microsoft.Net, Framework23 or 64 depends which one you're using.
2. remove all dlls from all bin folders, a simple Cleanup may not be sufficient.

With all this done, providing you have one version everywhere, you should be able to run you project without issues
I finally got this working. In order to do Assembly Redirect Binding in Azure Functions, it takes a little more effort than a normal `.Net` application.

I followed the following post:
<https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/>