Could not load file or assembly 'Leadtools.Codecs', if anyone is familiar with leadtools

tnw picture tnw · Sep 4, 2012 · Viewed 10.6k times · Source

I get an exception on the last line of the following code (sorry for the format, won't let me post it any other way):

LeadHelper.Unlock(); 
RasterCodecs codecs = new RasterCodecs(); 
string imageLocation = @"...path...\Barcodes.tif"; 
RasterImage srcImage = codecs.Load(imageLocation); 

The exception reads:

System.BadImageFormatException: Could not load file or assembly 'Leadtools.Codecs, Version=17.5.0.0, Culture=neutral, ..........' or one of its dependencies. An attempt was made to lead a program with an incorrect format.

In an effort to try to get rid of this exception, I referenced every possible Leadtools.Codecs.* DLL, Leadtools.dll... pretty much every single Leadtools dll we could possibly reference.

For my includes, I included Leadtools, Leadtools.Barcode, Leadtools.Codecs, Leadtools.Codecs.Tif, Leadtools.Codecs.Fax, and Leadtools.Forms

This is for a test console app I'm making to read barcodes... VS2010 C#.

Also, I most definitely have access to the file, it's a reference to a network file but have tried referencing it locally, checked permissions, etc etc

Answer

Daniel Hilgarth picture Daniel Hilgarth · Sep 4, 2012

The message typically means that you are trying to load a 32 bit DLL on a 64 bit system or vice versa.

Verify that you have the correct version of the DLLs and their dependencies.