I've got C# application that runs fine within Visual Studio, but I've extracted the references from the .csproj, and added the to the GAC as part of my installer.
However, when I run the application, when it invokes one of the references (System.Text.Json
) I get an Exception:
"System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
I've got System.Runtime.CompilerServices.Unsafe version 6.0.0
in the references in the .csproj, and it's looks like it's successfully installed by my installer.
I enabled Assembly Bind Failure Logging, and it looks like System.Memory
is referring to version 4.0.4.1 of System.Runtime.CompilerServices.Unsafe
.
Any tips or suggestions on how I could get the conflict resolved?
Updates:
It's a small application to provide the ability to move a astronomical telescope motor focuser. The tools provided by the vendor lack in some areas, and the SDK is pretty easy to use. My app is just a couple of forms that use the SDK API, and saves/loads named positions.I actually tried to add an app.config containing the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</configuration>`
but it still fails with the same exception.
The app.config is in the same directory as the executable, and has the same name (with the .config extension instead of .EXE).
Solved: it looks like I'm making things to hard on myself. Soleil's suggestion of using everything in the bin folder seems to work. I just have to update my installer properly now.