问题描述
我已经通过 Nuget 和 project.json 成功引用了一个可移植"程序集.我所有的代码都在 Azure 函数中编译,但是当它运行时我得到:
I've successfully referenced an assembly via Nuget and project.json that is a "Portable" assembly. All my code compiles in the Azure function, but when it's run I get:
无法加载文件或程序集System.Net,Version=2.0.5.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e,Retargetable=Yes"或其依赖项之一.系统找不到指定的文件.
Could not load file or assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.
据我了解,这是 System.Net 的便携版本,Azure 仅预装了 System.Net 4.6 版本.
As I understand it this is the portable version of System.Net, and Azure only preinstalls the 4.6 version of System.Net.
我该如何解决这个问题?
How do I work around this?
推荐答案
这是由当前 Azure Functions 主机里程碑上已解决的错误引起的,并将在下一个版本中部署(可能在本周末).您可以在此处找到有关此问题和修复的更多信息:https://github.com/Azure/azure-webjobs-sdk-script/issues/478
This is caused by a bug that has been addressed on the current Azure Functions host milestone and will be deployed with the next release (likely towards the end of the week). You can find more information about the issue and the fix here: https://github.com/Azure/azure-webjobs-sdk-script/issues/478
与此同时,一种解决方法是将 System.Net 从 Framework 文件夹复制到 bin 文件夹中,该文件夹位于函数文件夹内.宿主会自动将其解析为私有程序集.
In the meantime, a workaround would be to copy System.Net from the Framework folder into a bin folder, inside of your function's folder. The host will automatically resolve it as a private assembly.
这篇关于如何引用“便携式"?来自 Azure 云函数的 .NET 程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!