Azure Functions:启动操作期间发生主机错误无法加载文件 [英] Azure Functions: host error has occurred during startup operation Could not load file

查看:12
本文介绍了Azure Functions:启动操作期间发生主机错误无法加载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Microsoft.AspNetCore.Authentication.Facebook 与 Azure 函数项目一起使用.我创建了一个完全干净的 .net core 3.1 Azure Function 项目,仅具有以下依赖项:

I am trying to use Microsoft.AspNetCore.Authentication.Facebook with an Azure functions project. I created a completely clean .net core 3.1 Azure Function project only with the following dependencies:

Microsoft.NET.Sdk.Functions 3.0.7
Microsoft.Azure.Functions.Extensions 1.0.0
Microsoft.AspNetCore.Authentication.Facebook 3.1.5

在启动文件中我有以下代码:

In the startup file I have the following code:

 public override void Configure(IFunctionsHostBuilder builder)
 {           
     facebookOptions.AppId = Environment.GetEnvironmentVariable("Authentication:Facebook:AppId");
     facebookOptions.AppSecret = Environment.GetEnvironmentVariable("Authentication:Facebook:AppSecret");
 });

当我运行应用程序时,我在控制台窗口中收到以下错误:

When I run the application I get the following error in the console window:

> A host error has occurred during startup operation Could not load file
> or assembly 'Microsoft.AspNetCore.Authentication.Facebook,
> Version=3.1.5.0, Culture=neutral, PublicKeyToken='. The system cannot
> find the file specified.

知道可能出了什么问题吗?

Any idea what could be wrong?

推荐答案

有两种排错方式:

  1. 在配置文件中添加绑定重定向元素.

  1. Add binding Redirect element in config file.

<runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
     <assemblyIdentity name="Microsoft.AspNetCore.Authentication.Facebook" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
     <bindingRedirect oldVersion="3.1.4" newVersion="3.1.5" />
   </dependentAssembly>
 </assemblyBinding>

这指定使用哪个版本的程序集而不是旧版本.newVersion 中不一定需要指定较新的版本,newVersion 中也可以提供较早的版本.

This specifies which version of assembly to use instead of old version. It is not necessarily requires later version be specified in newVersion, earlier version can be provided as well in newVersion.

更新 NuGet 包

更新所有根项目中的 NuGet 包,然后在后续引用的项目(如果需要)中引用相同的包.

Update NuGet package in all root project and then in subsequent referred project (if required) where same package is referred.

更多细节可以参考这个文章.

For more details, you could refer to this article.

这篇关于Azure Functions:启动操作期间发生主机错误无法加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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