Solved

System.BadImageFormatException: Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format.

Posted on 2014-04-29
8
5,724 Views
Last Modified: 2014-04-29
System.BadImageFormatException: Could not load file or assemblyor one of its dependencies. An attempt was made to load a program with an incorrect format.

I havea 64 bit OS, I have a dll that I am building for ANy CPU /ANy CPU. This dll has a few other dll's
Not sure which dll is causing this issue
0
Comment
Question by:countrymeister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40029430
The exception should tell you which is the offending assembly. Check to make sure that one was compiled as Any CPU (or x64).
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40029469
If you are including that DLL in another project then it needs to be compiled for the same target as the app which will use it.

So, if the app using it is 32-bit, you need to build for 32-bit.
0
 
LVL 1

Author Comment

by:countrymeister
ID: 40029498
Kaufmed and Carl

I have three projects in my solution.
Project A is the windows service (has reference to B)
Project B is a Wcf service hosted in the windows service (has  a reference to C)
Project C is the class library which is referenced in B

Project A is built a Platform x86 , target platform x64
Project B built for any CPU, target platform AnyCPU
Project C built for any cpu , target platform  any cpu
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 40029534
You should either have them all set to "Any CPU", or have them all set to "x86".
0
 
LVL 1

Author Comment

by:countrymeister
ID: 40029590
I have tried doing that, There are two settings on the build configuration.
Can you let me know what they should be for project A , B and C

I have attached a screen shot
Target.png
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40029602
Since your Platform is "Active (x86)" then Platform Target should be "x86".
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40029607
Which assembly does the exception reference?
0
 
LVL 1

Author Comment

by:countrymeister
ID: 40029993
I got pass ed those errors now, by setting the both the targets to x86.
Now I get an error in installutil.exe
Exception ocurred while initializing the installation
System.IO.FileNotFoundException . Could not load file or assembly  or one of its dependencies.

I tried using the proper installutil.exe from
C:\Windows\Microsoft.NET\Framework\v4.0.30319
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question