by cncdrive » Sun Jul 15, 2018 1:26 pm
Hi Dan,
BadimageFormatException exception happens when a 32bits application tries to load a 64bits assembly or a 64bits application tries to load a 32bits assembly.
If the mentioned .dll file contains native code (not a .NET .dll) then the only solution for this problem is to have both the 32bits and 64bits version of the same dll and load the appropriate one depending on the platform the UCCNC is running on (32bits or 64bits Windows.)
The version 1.2047 was still compiled with x86, so it always runs as a 32bits process even on 64bits Windows and so that UCCNC version can always load 32bits dll files, but it can't load 64bits ones.
The newest UCCNC versions were compiled with AnyCPU and so they running as a 32bits process on 32bits Windows and as a 64bits process on 64bits Windows and so you will have to load the proper image format assemblies depending on what platform the software is running on.
We doing the same with the UC100.dll which is the motion control API of the UCCNC software and is a native code not .NET, so we have to have both 32bits and 64bits versions.
What we do is when the UCCNC startsup it checks if the platform is 32bits or 64bits and also checks if the UC100.dll version in the UCCNC folder is the 32bits or the 64bits version and if nessessary then it copies the proper .dll file into the folder before the software is calling any dllimport.
This way the software is easily portable between computers even with copying all files and folders without an installation, because the UCCNC always checks the .dll on startup and replaces with the proper one when nessessary.