Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, September 4, 2012 4:37:49 AM(UTC)

tnw  
tnw

Groups: Registered
Posts: 4


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

Any ideas?
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, September 4, 2012 4:39:02 AM(UTC)

tnw  
tnw

Groups: Registered
Posts: 4


The forum won't let me edit my post, but I figured I should include that I am trying to run a console app to read barcodes in VS2010 C#
 
#3 Posted : Tuesday, September 4, 2012 4:40:45 AM(UTC)

tnw  
tnw

Groups: Registered
Posts: 4


The forum won't let me edit my post, but I figured I should include that I am trying to run a console app to read barcodes in VS2010 C#
 
#4 Posted : Tuesday, September 4, 2012 4:45:21 AM(UTC)

tnw  
tnw

Groups: Registered
Posts: 4


And 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
 
#5 Posted : Tuesday, September 4, 2012 6:34:00 AM(UTC)

Ibrahim  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Hello,
Are you building your .Net project as "Any CPU" and run it on a 64-bit operating system?

If yes, you should NOT build your application with the "Any CPU" configuration. You must specifically build for either 32-bit (x86 CPU) or 64-bit (x64 CPU) because "Any CPU" will cause problems if you run the program on 64-bit systems and include 32-bit DLLs.
If you don't know how to change this configuration, please do the following:
1- From the Project menu, select [project name] properties.
2- From the build tab, change the "Platform target" from "Any CPU" to "x86 CPU" and include the 32-bit DLLs from our toolkit.
3- Build your project and run it. This should work on both 32-bit Windows and also 64-bit Windows.
4- If you only want to target 64-bit Windows and use our 64-bit DLLs, use the same steps above, but choose "x64 CPU" and include our 64-bit DLLs.

Also, if you are using the .Net FrameWork 4.0, you must add your references from the "Dotnet4" folder. If you are using older versions of the .Net framework, you must add your references from the "Dotnet" folder.

If the problem persists, please answer the following questions:
1. What is the operating system (Windows version) that you use? And is it 32-bit or 64-bit?

2. Try to isolate the problem in a small working project (NOT your full application) and send it to me in a ZIP or RAR file. Also, provide me with the exact steps to reproduce the problem using your project. You can post it here or send it to support@leadtools.com and mention this forum post. If you want to attach a file on the forums, do not use the Preview feature.
 
#6 Posted : Friday, October 14, 2016 10:51:35 AM(UTC)
BonzoFestoon

Groups: Administrators
Posts: 27

Was thanked: 1 time(s) in 1 post(s)

In case someone is searching for BadImageFormatException and comes across this post, I recently posted an article on our blog about the BadImageFormatException that explains what to look for when trying to solve this problem.

https://www.leadtools.com/blog/general/badimageformatexception-and-leadtools/
Gabriel Smith
LEAD Technologies, Inc.

LEAD Logo
 
#7 Posted : Wednesday, February 20, 2019 9:37:47 AM(UTC)
PradeepDone

Groups: Registered
Posts: 4


Even after making changes to the Platform target i am getting the same error. I have taken a 64bit dll and updated as AnyCpu in the platform target but still i can see the same error.

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

I am using Windows 8 machine




 
#8 Posted : Tuesday, February 26, 2019 1:39:40 PM(UTC)
Marcus Andra

Groups: Registered, Manager, Tech Support, Administrators
Posts: 107

Was thanked: 9 time(s) in 9 post(s)

Hello,

The instructions listed above does a great job of describing the debugging steps. To briefly summarize what causes the "BadImageFormatException", it's often one of two things.

1: The architecture of your application, either x86 or x64 bit, does not match the architecture of your DLLs. This means that if your application is using the 64 bit architecture, but you are using 32 bit (x86) DLLs, you will have this issue.

2: The architecture of your application, either x86 or x64 bit, is using a DLL that does not match the rest of your application. You will need to ensure that all your DLLs match the architecture of your program.


I have attached a zip file which contains screenshots of this debugging process conducted in Visual Studio 2017. Please be sure to check all the LEADTOOLS references to ensure that all the DLLs support the intended architecture. If you are still having this issue after reviewing the discussions of this post, please email us at support@leadtools.com.

File Attachment(s):
stepstocheck.zip (150kb) downloaded 183 time(s).
Marcus Andra
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#9 Posted : Tuesday, March 5, 2019 6:20:21 AM(UTC)
PradeepDone

Groups: Registered
Posts: 4


Even after changing to 64 bit i am still facing the same issue.
 
#10 Posted : Thursday, March 7, 2019 10:31:01 AM(UTC)
Marcus Andra

Groups: Registered, Manager, Tech Support, Administrators
Posts: 107

Was thanked: 9 time(s) in 9 post(s)

Hello,

I have emailed you regarding this issue. Please follow up with my email reply so we can discuss your application in greater detail.


Thanks,
Marcus Andra
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.128 seconds.