I have a webApi project that was throwing an exception about being unable to find System.Diagnostics.DiagnosticSource
library. I Added reference to the nuget packages with this file. But now I'm getting:
System.IO.FileLoadException: 'Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
Version I have in "packages" folder is 4.6.25519.03
How do i fix this issue?
csproj reference:
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
The Version
attribute does not have to match the version number in the packages folder for that package. In fact mine are set to
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
and the product version on the assembly is set to 4.6.26515.6 and I don't get any errors or warnings during compilation and the assembly is found at runtime.
What I suggest is
If these don't help, consider adding a binding redirect to your app.config
file.
User contributions licensed under CC BY-SA 3.0