我正在尝试将Microsoft.AspNetCore.Authentication.Facebook与Azure函数项目一起使用。我创建了一个完全干净的.net核心3.1 Azure Function项目,仅具有以下依赖关系:
Microsoft.NET.Sdk.Functions 3.0.7
Microsoft.Azure.Functions.Extensions 1.0.0
Microsoft.AspNetCore.Authentication.Facebook 3.1.5
在启动文件中,我有以下代码:
public override void Configure(IFunctionsHostBuilder builder)
{
facebookOptions.AppId = Environment.GetEnvironmentVariable("Authentication:Facebook:AppId");
facebookOptions.AppSecret = Environment.GetEnvironmentVariable("Authentication:Facebook:AppSecret");
});
运行应用程序时,在控制台窗口中出现以下错误:
> 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.在配置文件中添加绑定重定向元素。
<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中提供更早版本。
2.更新NuGet包
在所有根项目中更新NuGet软件包,然后在引用相同软件包的后续引用项目(如果需要)中更新。
有关更多详细信息,请参阅本文。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句