FAQ TBarCode .NET
Bad Image Format Exception After Deployment of a Web Application
Bad Image Format Exception After Deployment of a Web Application
The following applies to TBarCode .NET versions before 11.15.
You get a System.BadImageFormatException (an attempt was made to load a program with an incorrect format) after you have deployed your ASP. NET project to your IIS web server. During development there was no such problem.
Reason: Visual Studio is a 32 Bit application and the development server usually runs as 32 Bit process. Therefore the 32 Bit version of TECIT.TBarCode.DLL has been embedded into your project and is now part of your ./bin folder. But your IIS runs the worker thread as 64 Bit process and now loads the wrong format.
Option #1: Deploy the 64-Bit version of the Assembly
Use the version from the C:\Program Files\Common Files\TEC-IT\TBarCode\[version] folder (this is the x64 version). Exchange the ../bin/TECIT.TBarCode.dll file on your target system with that version.
Option #2: Let the GAC do the work
Remove the TECIT.TBarCode.dll completely from your bin folder. In that case the TECIT.TBarCode.dll from the global assembly cache (GAC) will be loaded. The common language runtime loads the correct version automatically because the GAC holds both versions, 32 and 64 Bit. Prerequisite: The setup of TBarCode SDK must be executed on the target server, the setup installs the DLLs in the GAC for you.