skip to Main Content

Background:- My project is of a class library having target .NET framework 4.8 and have installed the nuget Azure.Storage.Blobs(version 12.21.1 which is latest stable) in my class.

I’m encountering a problem with the nuget package dll of "System.Diagnostics.DiagnosticSource". In my error logs it states the Version of the dll as 6.0.0.0 although Azure.Core utilizes version 6.0.0.1.
I checked packages.config, csproj, app.config (Having bindingRedirect as well) and all refer to the same package version i.e 6.0.0.1.

I turned the assembly fusion logs on and they have the following:-


`The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\SysWOW64\dllhost.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
(Fully-specified)
LOG: Appbase = file:///C:/Windows/SysWOW64/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : Azure.Storage.Blobs, Version=12.21.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8.
=

LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/SysWOW64/System.Diagnostics.DiagnosticSource.DLL.
LOG: Attempting download of new URL file:///C:/Windows/SysWOW64/System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticSource.DLL.
LOG: Attempting download of new URL file:///C:/Windows/SysWOW64/System.Diagnostics.DiagnosticSource.EXE.
LOG: Attempting download of new URL file:///C:/Windows/SysWOW64/System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticSource.EXE.
LOG: Attempting download of new URL file:///C:/Users/agtoluser/Desktop/AzureDLL/R71/System.Diagnostics.DiagnosticSource.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\agtoluser\Desktop\AzureDLL\R71\System.Diagnostics.DiagnosticSource.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Diagnostics.DiagnosticSource, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
LOG: Attempting download of new URL file:///C:/Users/agtoluser/Desktop/AzureDLL/R71/System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticSource.DLL.
LOG: Attempting download of new URL file:///C:/Users/agtoluser/Desktop/AzureDLL/R71/System.Diagnostics.DiagnosticSource.EXE.
LOG: Attempting download of new URL file:///C:/Users/agtoluser/Desktop/AzureDLL/R71/System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticSource.EXE.
LOG: All probing URLs attempted and failed.

*** Assembly Binder Log Entry  (8/1/2024 @ 2:57:53 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.`

When I downgrade my NuGet package from 6.0.0.1 to 6.0.0.0, I encounter a different error: "Could not load file or assembly ‘System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’."

Attempting to switch from version 6.0.0.0 to 4.0.4.0 results in a compatibility issue with "Azure.Core" and "Azure.Storage.Blobs," which do not support System.Diagnostics.DiagnosticSource, Version=4.0.4.0. Despite having consistent references to version 6.0.0.1 in both my packages.config and the app.config of my new DLL, the error persists.

There was a similar question on stackoverflow, I attempted using it’s solution as well that is removed xmlns from assemblyBinding tag in app.config
Earlier:

Now:

But still the error is showing up. Please suggets some way out.

2

Answers


  1. Chosen as BEST ANSWER

    I moved the used Azure methods from Azure.Storage.Blobs nuget in a different DLL project(.NET Framework 4.8). I signed this DLL i.e made it strongly-named. This solved my issue.


  2. You are referencing library that is referencing .NET6, your project is made with .NET Framework 4.8, and those are incompatible versions.

    You are limited only to libraries and their versions compatible with your framework’s version.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search