Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0 in Azure Functions

I have an API and a separate Azure Functions app. I upgraded my API app to .NET 5 and it's working fine. In the API app's solution, I have class library projects that I also reference in my Azure Functions app. These class libraries are netstandard2.1 projects.

Ever since this update -- during which I also updated all my NuGet packages to latest versions -- my Azure Functions app stopped working. I'm getting the following error:

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. Value cannot be null. (Parameter 'provider')

I noticed that there were breaking changes involving the Microsoft.Extensions.* packages and their recommendation is to install the package that is causing the issue directly. So I added Microsoft.Extensions.Configuration.Abstractions to my Azure Functions manually -- before it was being installed as a dependency of Microsoft.Extensions.Configuration package. Here's the information about this: https://github.com/dotnet/aspnetcore/issues/21033

The issue still persists. I even tried downgrading Microsoft.Extensions.Configuration in both the API and Functions app, but I'm still getting the same error.

Any idea how to resolve this issue?

like image 596
Sam Avatar asked Nov 12 '20 18:11

Sam


2 Answers

Sam's comment should be accepted as correct answer. I try it out to downgrade Microsoft.Extensions* (in my case Microsoft.Extensions.Logging.Console) from 5.0.0 to 3.1.0 and the error just gone. Bravo!

like image 198
binaryDi Avatar answered Oct 31 '22 23:10

binaryDi


As a reference, this GitHub link explains exactly why that happens.

And as of now, you either track down the exact versions been referenced or downgrade everything to the latest v3 build.

In a nutshell, Azure Functions SDK already has some dependencies loaded in memory, so your libraries cannot use newer versions of the same libraries.

like image 21
Daniel Avatar answered Nov 01 '22 00:11

Daniel