I am referencing a third party dll that has both x64 and x86 versions. I am using the x64 version. There are no build warnings about mismatched bitness. This project runs fine from Visual Studio and running the .exe from the build folder on my local Windows 10 x64 machine, but when running on another machine with a clean Windows 10 x64 installation, however, as soon as the code that uses the referenced dll is hit, an error is thrown. I have spun up a Windows 10 x64 VM and can reproduce the problem there so it is not specific to any machine. My conclusion is that I have something installed on my machine that is allowing the program to behave correctly but that something is not installed on the other machines.
An attempt was made to load a program with an incorrect format.
I have tried switching the project platform to be x86 and reference the x86 version of the third part dll but get the same results.
Below is the project file.
<PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net5.0</TargetFramework> <RuntimeIdentifier>win10-x64</RuntimeIdentifier> <Platforms>x64</Platforms> </PropertyGroup>
Here is the full exception. The SATOPrinterAPI is the referenced dll. It looks like maybe the dll is loading another assembly that is having the issues.
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B) at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly) at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) at System.Reflection.Assembly.LoadFile(String path) at SATOPrinterAPI.EmbeddedAssembly.Load(String Resouces, String FileName)
User contributions licensed under CC BY-SA 3.0