gpt4 book ai didi

c# - 无法加载文件或程序集 'Microsoft.WindowsAzure.Storage' Azure Functions

转载 作者:行者123 更新时间:2023-12-02 20:27:17 26 4
gpt4 key购买 nike

我目前正在使用在 Visual Studio 中创建的 Azure 函数。它是一个计时器函数,调用一些通用代码来写入队列。

在本地运行代码不会导致任何问题。运行得很好,但发布时出现以下错误:

Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.||System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Esperanto.Core.Function.JobGetterLogic.SendJobsToQue() at JobGetter.TimedJob.Run(TimerInfo myTimer, TraceWriter log)

这是我的网络作业代码:

public static class TimedJob
{
[FunctionName("TimedJob")]
public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
try
{
var brain = new CoreLogic.Function.JobGetterLogic();
var result = brain.SendJobsToQue();
}
catch (Exception e)
{
log.Info(e.Message + "||" + e.ToString());
}

}
}

最佳答案

我的问题是因为 Newtonsoft.Json 版本,但我什至在发布之前安装 WindowsAzure.Storage 包时就得到了这个问题。

它在输出中给了我这个:

NU1107: Version conflict detected for Newtonsoft.Json. Reference the package directly from the project to resolve this issue.
PMTool.AzureFunctions -> WindowsAzure.Storage 9.1.0 -> Newtonsoft.Json (>= 10.0.2) PMTool.AzureFunctions -> Microsoft.NET.Sdk.Functions 1.0.6 -> Newtonsoft.Json (= 9.0.1).

然后回滚。

因此 Functions SDK 中的 Newtonsoft.Json 版本为 9.0.1,但在 Azure 存储上为 10.0.2。

并且可以肯定,如果像这样发布它会出现此错误:

"Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

因为根本没有被引用。

这可能不是您的确切问题,但它可能会给您提供线索。

关于c# - 无法加载文件或程序集 'Microsoft.WindowsAzure.Storage' Azure Functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49591628/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com