1

I've an Azure Function project (.NET Framework) and I've this NuGet packages installed.

<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.4" />
<PackageReference Include="Microsoft.Graph" Version="1.17.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Swagger" Version="1.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />

The project has also an other reference to an other created project. There I've next dependancies:

<package id="Microsoft.Azure.KeyVault" version="3.0.5" targetFramework="net472" />
<package id="Microsoft.Azure.KeyVault.WebKey" version="3.0.5" targetFramework="net472" />
<package id="Microsoft.Azure.ServiceBus" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Graph" version="1.17.0" targetFramework="net472" />
<package id="Microsoft.Graph.Core" version="1.17.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />

When I run a function, I got this Error:

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.

What's wrong with the packages? I've been searching a day for a solution but the only thing I find is that the dependencies of each packages uses an different version of Newtonsoft.Json. The Newtonsoft dependency of Microsoft.NET.Sdk.Functions must be 9.0.1, while others stand on 10.0.3 or higher.

How could I solve this?

H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
  • 2
    Make sure that you reference the same version of the assembly across all projects or use [binding redirects](https://stackoverflow.com/questions/46111749/adding-a-bindingredirect-to-a-net-standard-library). – mm8 Mar 12 '20 at 13:38
  • Use Azure Function V3 should solve this problem. – Cindy Pau Mar 12 '20 at 14:50

2 Answers2

1

newtonsoft json version is = not >=. This problem has been around for a long time, MS tracking this work here: https://github.com/Azure/azure-functions-vs-build-sdk/issues/304

Create function v3 to avoid this error.

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
0

As per doc, the version specified is the lowest version required. You can learn more about package versioning here.

Community
  • 1
  • 1
kartheekp-ms
  • 130
  • 2