dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.96k stars 4.65k forks source link

.NET Framework 4.8 Class Library compatibility issue with Azure.Storage.Blob package #93177

Closed RitaAguiar closed 11 months ago

RitaAguiar commented 11 months ago

Description

I have built a .NET Framework 4.8 Class Library project to run on top of Autodesk Revit (building information modeling tool). I added only 3 packages:

I want to be able to list files from a storage account container. However, there seems to be some incompatibilities between .NET Framework 4.8 Class Library and the Azure.Storage.Blob package.

Reproduction Steps

Pls refer to the test-azure-revitapi repo where I made a minimal .NET Framework 4.8 Class Library project. You need Autodesk Revit 2023 to run this plugin.

Expected behavior

The expected behavior is to be able to initialize an instance of BlobServiceClient class (Azure.Storage.Blob).

Actual behavior

In the minimal project, this is the error obtained:

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
Inner Exception
FileNotFoundException: Could not load file or assembly 'Azure.Storage.Blobs, Version=12.18.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The system cannot find the file specified.

The project that I'm working on and that I cannot share here has the same 3 packages plus many others. The error I get is:

System.TypeInitializationException: 'The type initializer for 'Azure.Core.Pipeline.DiagnosticScopeFactory' threw an exception.'
Inner Exception
TypeLoadException: Could not load type 'System.Diagnostics.ActivitySource' from assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

Regression?

I have not found a previous release where this works. However, I built a minimal project with .NET Framework 4.8 Console App with the same packages that works as expected.

Known Workarounds

No workarounds I have found. However, I built a minimal project with both a .NET Framework 4.8 Class Library and a .NET Framework 4.8 Console App. The .NET Framework 4.8 Class Library project results in the problem mentioned above. The .NET Framework 4.8 Console App project with the same packages works as expected. Upgrading the project to .NET 5 or .NET 6 is not really an option given that the RevitAPI might not behave as expected.

Configuration

.NET Framework 4.8 Class Library Windows 11 Any CPU

Other information

I believe there must be some package using the System.Diagnostics.DiagnosticSource, it could potentially be the Revit API packages, however, I built a Console App that includes those packages despite not being in use, and it behaves as expected, this is, I'm able to list the files in the container. Azure Storage Blob package seems to use the System.Diagnostics.DiagnosticSource version 7.0.2.0. However, the error I'm getting on the main project I'm working on is that is it looking for the System.Diagnostics.DiagnosticSource version 4.0.1.0.

jeffschwMSFT commented 11 months ago

@RitaAguiar Visual Studio developer community is the best place for .NET Framework questions.

https://developercommunity.visualstudio.com/home

Once you have filed feedback there, please post it back here to connect them. I can help route to the appropriate team.

jeffschwMSFT commented 11 months ago

once a VS developer community issue has been filed, please let us know

nicolaslcalvi commented 10 months ago

Same problem an I found a workaround for that, tested on Revit 2024 Api. Install the version 12.17.0 of Azure.Storage.Blobs from Nuget and don't update anything !

m-redding commented 10 months ago

@RitaAguiar there's a discussion about this in the azure-sdk-for-net repo in this issue: https://github.com/Azure/azure-sdk-for-net/issues/39798