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?
There are two ways to troubleshooting:
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>
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.
Update NuGet Package
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.