[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
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
Medium Priority
?
6,347 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
  • 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
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

873 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