Azure Functions中的程序集绑定重定向 [英] Assembly binding redirect in Azure Functions

查看:79
本文介绍了Azure Functions中的程序集绑定重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Azure函数,并且我们知道它具有Microsoft.NET.Sdk.Functions 1.0.8软件包,该软件包依赖于Newtonsoft.Json 9.0.1.

I have created an Azure function and as we know it has the package Microsoft.NET.Sdk.Functions 1.0.8 which is dependent on Newtonsoft.Json 9.0.1.

我添加了另一个类库作为对此Azure函数的引用,该函数依赖于Newtonsoft.Json 11.0.2.

I have added another class library as a reference to this Azure Function which depends on Newtonsoft.Json 11.0.2.

在运行时,出现错误提示:

During runtime, I get an error stating:

"FileNotFoundException:无法加载文件或程序集 'Newtonsoft.Json,版本= 11.0.0.0,文化=中性, PublicKeyToken = 30ad4fe6b2a6aeed"或其依赖项之一.这 系统找不到指定的文件."

"FileNotFoundException: 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."

这看起来像是与程序集绑定重定向相关的问题,因此我按照此解决方案进行尝试并修复 https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/ 但是,这也无济于事.

This looks like a problem related to Assembly Binding Redirects so I follow this solution to try and fix https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/ But, this doesn't help as well.

在这种情况下,我是否缺少步骤或任何其他解决方法?感谢您的帮助.

Is there a step that I'm missing or any other workaround for this kind of case? Help is appreciated.

推荐答案

Azure函数没有绑定重定向的概念.如果您的函数应用有对依赖于Newtonsoft.Json特定版本(例如x版本)的库的引用,而Microsoft.Net.Sdk.Functions隐含依赖于另一个版本(例如y版本),则可以添加显式引用作为解决方法.通过在Package Manager控制台上运行它,将其转换为功能应用程序中Newtonsoft.Json的x版本.

Azure functions don't have a notion of binding redirect. If your functions app has a reference to a library that depends on a specific version (say version x) of Newtonsoft.Json and the Microsoft.Net.Sdk.Functions has implicit dependency on another version (say version y), as a workaround you can add explicit reference to version x of Newtonsoft.Json in your functions app by running this on your Package Manager Console.

Install-Package Newtonsoft.Json -Version x

这将使您的项目依赖项显示黄色警告标志,但不会出现运行时错误.

This will make your project dependency show a yellow warning sign but you won't get a runtime error.

这篇关于Azure Functions中的程序集绑定重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆