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

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

问题描述

我正在尝试将Microsoft.AspNetCore.Authentication.Facebook与Azure函数项目一起使用.我创建了一个完全干净的.net核心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.

有什么主意吗?

推荐答案

有两种故障排除方法:

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>
  </runtime>

这指定要使用的程序集版本,而不是旧版本.不一定需要在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.

2.更新NuGet程序包

2.Update NuGet Package

在所有根项目中更新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功能:启动操作期间发生主机错误无法加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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