【问题标题】:Azure Function: Could not load file or assembly Newtonsoft.JsonAzure 函数:无法加载文件或程序集 Newtonsoft.Json
【发布时间】:2020-11-01 07:39:00
【问题描述】:

我知道这个问题在网络和 stackoverflow 上得到了广泛的报道,但我可以通过一些额外的帮助来解决这个问题。我收到与加载 Newtonsoft 相关的运行时错误,见下文;

[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)

我已经按照in this blog 的描述遵循并实施了绑定重定向。我的天蓝色函数是带有 .net472 的版本 1 函数,我使用的是 Microsoft.NET.Sdk.Functions 版本 1.0.36。

当调用引用的项目时发生异常,在该项目中有对 Newtonsoft 10.0.2 的引用。

非常感谢任何帮助 - 谢谢!

【问题讨论】:

标签: c# azure azure-functions


【解决方案1】:

您需要将 Newtonsoft 降级到 9.0.1。您最好阅读有关 v1/v2 重大更改并将您的函数重写为 .net 核心的信息。

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

【讨论】:

  • 抱歉,没有提及引用的项目使用 Microsoft.Azure.Cosmos.Table,其中包含 Newtonsoft.Json (>= 10.0.2) 依赖项。
  • 你最好重写并使用.net core。抱歉,v1 被认为是旧版,您将面临这种依赖冲突。值得一提的是,旧包可能包含性能/错误。所以强烈建议使用最新版本。
  • 我被困在 V1 上的原因之一是使用了 EF6。但是我做了一点研究,发现最新版本的 EF6 可以在 .net 内核上运行。做了开关,工作。头痛消失了-谢谢伙计
猜你喜欢
  • 2014-04-08
  • 1970-01-01
  • 1970-01-01
  • 2018-10-13
  • 2018-11-29
  • 2017-12-31
  • 1970-01-01
  • 2018-09-10
  • 2018-09-12
相关资源
最近更新 更多