Could not load file or assembly ‘PresentationCore’ or one of its dependencies. An attempt was made to load a program with an incorrect format. : A solution

Few days back, I was migrating my application for VS2008 to VS2010 and it was done successfully except  some people started running the application. They faced the error as below

Could not load file or assembly ‘PresentationCore’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

I tried to diagnose the problem and tried to find a solution.

So whenever you  upgrade to VS 2008 to VS 2010 and also upgrade ASP.NET version to 4.0. And if your website hosted on IIS, when you open your VS 2010 IDE it prompt a message asking to upgrade to asp.net version to 4.0. When you say yes it upgrades the version at IIS.

So let’s come back to our original problem. When I diagnosed I found the machine was having 64bit OS.

And at IIS, there is setting “Enable 32-bit Applications” at application pool level that is by default set false . So if you are having 64 bit OS and your application target 32-bit applications then this property must be true.

So how to set it. I have included the images for IIS7.  So first you need to know, which application pool your virtual directory points. So to check this

Goto -> cmd prompt -> type inetmgr -> click on your virtual directory and click on basic settings

Basic settingsNow you can see the Red oval that that is the name of Application pool set for this directory.

Now click on Application pool-> Click on DefaultAppPool -> and click on Advance settings.

App pool advance settings

Here you can see Red oval, I have set Enable 32-bit Applications to true.  Now restart the IIS.

Now run your application and it must be working.

Cheers,

Brij

Brij

Brij is a Microsoft MVP in ASP.NET/IIS Category and a passionate dot.net developer. Having around 4.5 years of experiance in IT field, currently serving a MNC as a Sr. developer. He is alsoMVP at CodeProject He is a very passionated .NET developer and have expertise over Web technologies like ASP.NET 2.0/3.5/4.0, jQuery, JSON, Javascript, IIS and related technologies. He is also a Exchange Server (EWS) Specialist. He has great experience in design patterns and N-Tier Architecture. He is also certified as Microsoft Certified Technologies Specialist-ASP.NET and Microsoft Certified Technologies Specialist-WCF in .NET 4.0. He has also recieved several awards at various forums and his various articles got listed as "Article of the day" at ASP.NET Microsoft Official Website www.asp.net. He has done MCA from NIT Durgapur and completed his graduation from Lucknow University. Learning new technologies and sharing knowledge excites him most. Blogging, solving problems at various forums, helping people, keeps him busy entire day. He has a great passion to learn new Microsoft Technologies and love to share the Knowledge. Visit his Blog: Brij's arena of .NET Follow him at Twitter : @brij_bhushan