Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions

I am deploying a function and I am able to build and publish it successfully in a function app V2 from Visual studio, but in the azure portal I see the below message inside my function app. I have added the necessary package but still its of no use. Has anyone come across this error and have any feedback. There is no error in the Output window of Visual studio as well.

If I remove this version of abstraction then it says file not found with version 3.1.5. When i add the version 3.1.5 then it says file not found. No clue what is wrong. there is a discussion in github but that thread is closed now without much information

Thanks

System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb97829ddae60'. The system cannot find the file specified. System.Private.CoreLib: Could not load the specified file.

like image 923
Ankit Kumar Avatar asked Nov 13 '20 15:11

Ankit Kumar


3 Answers

I have just come across a similar issue. For me the problem was I had included one of the Microsoft.Extensions.xxx packages with Version="5.0.0" but my target framework was netcoreapp3.1.

Changing the version of the referenced extension package to the same as my target framework resolved the error.

E.g.

Change:

<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />

To:

<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.10" />

The real problem was I ran dotnet add package Microsoft.Extensions.xxx without specifying the version so it just added the latest available.

like image 143
mfa Avatar answered Oct 17 '22 14:10

mfa


I fixed it by changing the Function runtime version. It was set to ~2 . I changed it to ~3 and that made the error go away.

You can do it in Function App -> Configuration -> Function runtime

like image 43
Ankit Kumar Avatar answered Oct 17 '22 14:10

Ankit Kumar


I had the issue too, The changed the version to 2.1.1 and it works for me.

like image 1
Chamath Jeevan Avatar answered Oct 17 '22 15:10

Chamath Jeevan