0

I'm calling JToken.FromObject() and it is throwing:

Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified

This is an Azure Function based on .Net Core 2.1 using Newtonsoft JSON 12.0.3

It is failing on my dev PC

Any ideas how to fix this, please?

stuartd
  • 70,509
  • 14
  • 132
  • 163
radders
  • 923
  • 8
  • 29
  • @ColinM would the GAC apply when running as an Azure function? – stuartd Feb 17 '20 at 15:44
  • 1
    This [GitHub issue](https://github.com/Azure/azure-functions-core-tools/issues/479) also highlights this issue, with some workarounds in a linked [StackOverflow post](https://stackoverflow.com/questions/50342416/azure-function-ef-core-cant-load-componentmodel-annotations-4-2-0-0/50770897). I've removed my previous comments as I realize I've gone around in a circle in what I was saying. .NET Core will be used locally & on Azure so the GAC won't be used at all. – ColinM Feb 17 '20 at 15:48
  • I added a package reference to v4.5.0 as this is the lowest version some other packages would accept, but still get exactly the same error... – radders Feb 17 '20 at 16:00

1 Answers1

0

Updating the Azure function project to core 3.1 solved the problem...

radders
  • 923
  • 8
  • 29