'how to fix this error "Microsoft.Extensions.Azure: Could not load file or assembly 'System.Diagnostics.Tracing, Version=5.0.0.0,"

there’s a problem that I didn’t understand where it came from because the script worked yesterday , I woke up and I found this problem that wasn’t there yesterday. I’m working on a project (net 5.0) that contains Azure Function ,Entity Framework Core ,Microsoft Graph.

Error :

Microsoft.Extensions.Azure: Could not load file or assembly 'System.Diagnostics.Tracing, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Impossibile trovare il file specificato.


Solution 1:[1]

Could not load file or assembly 'xxx'

This kind of problem is usually caused by version incompatibility. Upgrading or downgrading the assembly should be able to solve your problem.

Solution 2:[2]

If you updated yur function to .NET 6, you need to use Azure Functions v4. Add this below to the function configuration in the Azure portal:

FUNCTIONS_EXTENSION_VERSION = "~4"

Solution 3:[3]

I upgraded from version3 to version 4 and it was working in my local environment, but not on Azure Portal. I removed:

[assembly: FunctionsStartup(typeof(Startup))]

…but that caused another issue with dependency injection.

The solution was to change FUNCTIONS_EXTENSION_VERSION to ~4 in Azure Portal in Configuration.

Solution 4:[4]

I finally fixed this. I was unable to Publish from Visual Studio 2019 by using the normal Publish method. I followed these instructions and now I'm no longer missing any files.

https://demiliani.com/2020/03/26/a-quick-way-to-deploy-your-azure-functions-in-the-cloud/

Solution 5:[5]

I had the same issue after upgrading to Azure Function v4 caused by an outdated Azure Function Core Tools (download the latest version here.)

You can check your Function Core Tools version using func version. Be sure it is > 4.0 when using Azure Function v4!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank Gong
Solution 2 cuasijoe
Solution 3 Jeremy Caney
Solution 4 Dumber_Texan2
Solution 5 Martin Brandl