[Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I have recently switched my development environment from 32-bit to 64-bit by installing Windows Server 2008 64-bit and modify it to be used as workstation as described here http://www.win2008workstation.com/ and I'm really amazed with it’s performance.

I have faced the problem mentioned in the post title when I'm trying to run a web application included in one of our development solutions.

couldnot load

I have checked the project which has the DBHelper as it’s output and I’ve discovered that the project configured to target x86 platform and as I'm working with 64-bit it will have such ‘incorrect format’ error.

How to fix it:

Simply follow the steps below :

  • open project properties window.
  • select Build tab
  • Change it to ‘Any CPU’
  • Save your changes.
  • Compile your project and run :)

image

Published Sunday, October 11, 2009 4:04 PM by Hosam Kamel

Comments

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Sunday, October 18, 2009 6:45 AM by Gopalakrishnan

Hi,

I have a web site project (VS 2008) that has the build configuration set to Any CPU but still getting the same error for an assembly. Any other steps to solve this?

Thanks,

Gopalakrishnan

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Sunday, October 18, 2009 7:48 AM by Hosam Kamel

Hello Gopalakrishnan,

please make sure you have did so for all dependencies your website uses.

You can also enable 32-bit mode on IIS and adjust your website and its dependencies to target 86x platform.

let me know if this doesn't work for you.

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Thursday, December 31, 2009 12:59 AM by Feras

Thank you so much your few lines, fix one day of failed research

I'm using Windows 7 64 bit , however it works fine when i switch to x86 !!!

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Monday, March 1, 2010 4:34 PM by Mateo

Thanks a bunch.  Spent about an hour before finding this post. Glad I got luckly and didn't waste a day or more.

Changing the dependent project to 'Any CPU' worked for me.

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Friday, April 9, 2010 1:04 PM by Yuri

I figured out it happened for my WCF project in case I added string

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

in my web.config inside service configuration section. As I remove it, everything works fine.

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Tuesday, June 15, 2010 5:57 PM by Dean

Thanks man. Saved me some time with this post :)

D.

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Monday, September 13, 2010 5:27 PM by DannyC

Thanks for the hint! Saved me hours of searching, had already invested a couple of hours trying everything else!

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Friday, September 30, 2011 11:07 AM by manoj22184

Thanks Man

# re: [Resolved] Could not load file or assembly 'XXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Thursday, November 3, 2011 10:29 AM by bubba

Great.  Thanks for the help!

Leave a Comment

(required) 
(required) 
(optional)
(required)