I have a large, old, monolithic application that currently targets .NET Framework 4.7.2 and uses several recently-written modules (also targeting
net472) with no issues. There is also a recently-written module that targets .NET Standard 2.0, and it's giving me some problems.
All modules are loaded into the main application using Nuget packages.
When attempting to call the principal method of the module (i.e., at runtime, in the deployed application), it errors out saying that it failed to find a particular version of
System.Diagnostics.DiagnosticSource, despite that DLL existing in the appropriate
The dependency on
System.Diagnostics.DiagnosticSource comes from
Microsoft.EntityFrameworkCore.SqlServer, which has dependencies on it via both
I had suspected that the fact that an EntityFrameworkCore package is being called from a
net472 application would have something to do with it (and it still may), but the existing
net472 modules also use the Core package without errors. The exact same version, even!
\bin\Debugfolder into the
\binfolder at the application's install directory.
What Hasn't Worked
System.Diagnostics.DiagnosticSourceNuget package into the module. I have tried 220.127.116.11 (what the error message claims to be looking for), 4.5.0 (what the other modules expect), and 4.5.1 (what I think corresponds to the file version already in the install directory, see below).
net472project in the module's solution to consume the
netstandard2.0project without Nuget, then redirecting the main app to use that project via a DLL reference.
What Has Worked
\bindirectory to contain only the new module's desired version of
System.Diagnostics.DiagnosticSource.dll, namely file version
\binfolder already contains version
4.6.26919.2, but the module doesn't like that one.
This is a kludge, though. I shouldn't have to package two versions of the same DLL just because I have a Nuget package built on .NET Standard......should I?
Where do I go from here?
Here's the relevant fuslogvw entry. Note that it claims to be looking for version 18.104.22.168, despite
MyApp.exe.config having a redirect specifying
0.0.0.0-4.5.1, and despite VS showing
Microsoft.EntityFrameworkCore's dependency as
*** Assembly Binder Log Entry (10/28/2019 @ 1:22:30 PM) *** The operation failed. Bind result: hr = 0x80131040. No description available. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable C:\myApp\install\MyApp.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = System.Diagnostics.DiagnosticSource, Version=22.214.171.124, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (Fully-specified) LOG: Appbase = file:///C:/myApp/install/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = MyApp.exe Calling assembly : Microsoft.EntityFrameworkCore, Version=126.96.36.199, Culture=neutral, PublicKeyToken=adb9793829ddae60. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\myApp\install\MyApp.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Redirect found in application configuration file: 188.8.131.52 redirected to 184.108.40.206. LOG: Post-policy reference: System.Diagnostics.DiagnosticSource, Version=220.127.116.11, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/myApp/install/System.Diagnostics.DiagnosticSource.DLL. LOG: Attempting download of new URL file:///C:/myApp/install/System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticSource.DLL. LOG: Attempting download of new URL file:///C:/myApp/install/bin/System.Diagnostics.DiagnosticSource.DLL. LOG: Assembly download was successful. Attempting setup of file: C:\myApp\install\bin\System.Diagnostics.DiagnosticSource.dll LOG: Entering run-from-source setup phase. LOG: Assembly Name is: System.Diagnostics.DiagnosticSource, Version=18.104.22.168, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: The assembly reference did not match the assembly definition found. ERR: Run-from-source setup phase failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Here is the entry from
<dependentAssembly> <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.5.1" newVersion="4.5.1" /> </dependentAssembly>
It appears that the answer is "like any other redirects."
The fuslogvw dump showed the exact problem, and explains all the other errors I've been seeing. The DLL that I wanted to consolidate to (the one being used by all other modules, i.e., file version 4.6.26919.2) is not assembly version 4.5.1, but 22.214.171.124.
Correcting the binding redirect in
myApp.exe.config resolved the problem.
User contributions licensed under CC BY-SA 3.0