0

Heyya,

We recently went through with upgrading all our projects from .NET Core 3.0 to 3.1, as well as most of the associated NuGet packages. The projects themselves are hosted as services and function-apps on portal.azure.com, and is transferred via a Bitbucket repository (pushed up from development, pulled down automagically by Azure).

This worked great for two out of three services, but the last one have proved to be difficult. The service itself is working fine, and it's (seemingly) doing what it should when testing it via localhost, but the associated Function-app is throwing "System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0>'. The system cannot find the file specified." at us.

After some investigating, it would seem there was no Microsoft.Extensions.Logging.Abstractions package installed at all according to our NuGet Manager, but it was still being used by ILogger in the code (explanations for this one are very welcome). Nevertheless, we forced a downgrade to Microsoft.Extensions.Logging.Abstractions version 3.1.10, tested the application via localhost before deploying it, and this time we got the exact same error message, thrown in Program.cs. Guessing this wouldn't make things better even if we tried pushing it up.

The target version of the function-app is ~3 (only ~3 and ~1 is available, not ~2), and it has worked prior to this. The AzureFunctionVersion (available in the project's configuration files) is v3. Re-creating the function-app on the Portal does not seem to have made any difference.

Xariez
  • 759
  • 7
  • 24
  • This issue I'm answering every day for the last two weeks. Don't have an answer yet. See : https://stackoverflow.com/questions/67316994/using-net-core-3-1-c-sharp-dll-in-c-project?force_isolation=true#comment118992422_67316994 – jdweng Apr 30 '21 at 14:37
  • 1
    We had the same issue just today, but explicitly using 3.1.14 instead of 5.0.0 of the dependency fixed things for us. This happens often for Azure Functions: https://github.com/Azure/Azure-Functions/issues/1729 – Alex AIT Apr 30 '21 at 14:44
  • @AlexAIT Tried experimenting around with other solutions, and downgrading some packages to 3.1.14 seems to have done the trick. It's now seemingly not finding System.ComponentModel.Annotations 5.0.0.0, but at least it's progress – Xariez May 02 '21 at 18:02

1 Answers1

1

This usually happens when a Nuget package version is used by different nuget packages internally and is incompatible for at least one of them.

It means, there is a Nuget package in your project which requires Microsoft.Extensions.Logging.Abstractions version 5.0.0.0, but Azure Function latest version as of now installs version 2.1.1.

So, the solution is to upgrade Microsoft.Extensions.Logging.Abstractions version to 5.0.0.0 as SDK supports > 2.1.1:

enter image description here

enter image description here

OR

downgrade the dependent nuget package so that it uses 2.1.1 (or whichever version is installed in your project)

Harshita Singh
  • 4,590
  • 1
  • 10
  • 13
  • So, option 1 is to install Microsoft.Azure.WebJobs 3.0.27 and Microsoft.NET.Sdk.Functions 3.0.11 in the development environment, push it up, and it should work is what you're saying? Or did I misunderstand something here? – Xariez Apr 30 '21 at 18:36
  • No, as I said above, upgrade Microsoft.Extensions.Logging.Abstractions to 5.0.0 as it is used by another nuget package (other than SDK) – Harshita Singh Apr 30 '21 at 18:45
  • Does this help? – Harshita Singh Apr 30 '21 at 19:40
  • We already tried upgrading the package to 5.0.0 unfortunately, but the only thing it changes is that it works in Localhost (if we downgrade it, the project asks for 5.0.0). Nothing changes on Azure, and it still doesn't seem to find Microsoft.Extensions.Logging.Abstractions 5.0.0. – Xariez May 01 '21 at 15:24
  • Can u check which other nuget package is using this package? Also, which method is throwing error? Pls share stack trace – Harshita Singh May 01 '21 at 17:08
  • Tried experimenting around with other solutions, and downgrading some packages to 3.1.14 seems to have done the trick. It's now seemingly not finding System.ComponentModel.Annotations 5.0.0.0, but at least it's progress, and I guess it invalidates what works/doesn't work for the initial problem. – Xariez May 02 '21 at 18:02
  • Yes, it is a different problem's solution. But, the key is that you will have to adjust the nuget packages to use same version of `Microsoft.Extensions.Logging.Abstractions`. Hope you understood my response. – Harshita Singh May 02 '21 at 18:23
  • If adjusting the versions in a way I mentioned in previous comment works for you, pls mark this response as answer to help other community members who might face same issue. – Harshita Singh May 02 '21 at 18:24
  • 1
    Absolutely understood your response. I'd like to have it working to 100% before marking anything as solved, but there's a good chance your answer is "the one" – Xariez May 02 '21 at 19:52
  • 1
    We now have the service up and running. The solution was (much based on what you and others suggested) to downgrade some packages to 3.1.14, and actually make sure all the required packages are installed. We also had to install the ApplicationInsights connected service in Visual Studio. – Xariez May 03 '21 at 07:49