Azure Function:无法加载文件或程序集Newtonsoft.Json

5

我知道这个问题在网上和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)

我已按照此博客中所述的进行了绑定重定向的实现。我的Azure函数是一个版本为1,并且使用.NET 472,我正在使用Microsoft.NET.Sdk.Functions Version 1.0.36。

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

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


https://dev59.com/w1oT5IYBdhLWcg3wlgTn#47923538 - Sajeetharan
1个回答

3

抱歉,之前没有提到参考项目使用了 Microsoft.Azure.Cosmos.Table ,其中包含了 Newtonsoft.Json (>= 10.0.2) 的依赖项。 - horHAY
你最好重写并使用 .net core。抱歉,但是 v1 被认为是遗留的,你将面临依赖冲突的问题。值得一提的是,旧的包可能会存在性能 / 缺陷问题。因此,强烈建议使用最新版本。 - Thiago Custodio
我陷入V1的困境之一是因为使用了EF6。但我做了一些研究,发现最新版本的EF6适用于.NET Core。进行了切换,工作正常。头痛问题解决了 - 谢谢伙计! - horHAY

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接