5

I'm aware that this issue is widely covered on the web and at stackoverflow but I could do with some extra help to sort this issue. I'm getting a runtime error relating to loading Newtonsoft, see below;

[11/07/2020 18:37:17] A ScriptHost error has occurred
[11/07/2020 18:37:17] Exception while executing function: Alerts. EmailSender: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. mscorlib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
[11/07/2020 18:37:17] Exception while executing function: Alerts
[11/07/2020 18:37:17] Exception while executing function: Alerts. EmailSender: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. mscorlib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
[11/07/2020 18:37:17] Function completed (Failure, Id=850be268-8e38-409d-aa59-fa071567779e, Duration=10672ms)

I have followed and implemented binding redirects as described in this blog. My azure function is a verion 1 function with .net472, im using Microsoft.NET.Sdk.Functions Version 1.0.36.

The exception occurs when a call to a referenced project is made, in that project there is a reference to Newtonsoft 10.0.2.

Any help is greatly appreciated - thanks!

horHAY
  • 788
  • 2
  • 10
  • 23
  • https://stackoverflow.com/questions/38408167/could-not-load-file-or-assembly-system-net-http-version-4-0-0-0-culture-neutr/47923538#47923538 – Sajeetharan Jul 11 '20 at 18:58

1 Answers1

3

You'll need to downgrade Newtonsoft to 9.0.1. You'd better read about the v1/v2 breaking changes and rewrite your function to .net core.

https://github.com/Azure/app-service-announcements/issues/129

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • Sorry, failed to mention the referenced project uses [Microsoft.Azure.Cosmos.Table](https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Table) which contains a Newtonsoft.Json (>= 10.0.2) dependency. – horHAY Jul 11 '20 at 20:23
  • you'd better rewrite and use .net core. Sorry but v1 is considered legacy and you'll face this dependency conflict. It worths to mention that old packages can contain performance / bugs. So it's highly recommended to use latest versions. – Thiago Custodio Jul 11 '20 at 20:26
  • One of the reasons I was stuck on a V1 was due to the use of EF6. But I have done a little research and discovered that the latest version of EF6 works on .net core. Made the switch, works. Headache gone - thanks mate – horHAY Jul 11 '20 at 21:53