You may see a
System.BadImageFormatException the first time you access the Gurobi .NET assembly.
The Gurobi .NET assembly (e.g. gurobiXX.NET.dll) is compiled for AnyCPU (64-bit preferred). Your application needs to ensure that the proper native library (gurobiXX.dll) is used at runtime for the target platform.
A BadImageFormatException occurs if you mix 32/64 bit libraries at the moment when the .NET runtime loads the native library. At runtime, each .NET application is JIT compiled to either a native x64 or x86 application depending on the system. For applications where it is necessary to use native libraries (like with Gurobi), we recommend to explicitly create and use x64 and x86 build configurations and remove "AnyCPU" build configurations in Visual Studio.