In this article I will provide solution to solve the error (exception):- Could not load file or assembly ‘XYZ’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
This error comes when the website or web application is hosted in IIS Server versions IIS 7 and IIS 8.
 
The Problem
When a website or web application is hosted in IIS Server versions IIS 7 and IIS 8 the following error occurs.
Could not load file or assembly ‘XYZ’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
 
The Cause
In 64 Bit windows server operating systems, by default 64 Bit .Net Framework installed and hence when you try to deploy a 32 Bit web application (website) on IIS Server it results in an error.
 
The Solution
The solution to this problem is to enable 32 bit Applications in Application Pool of IIS Server.
Following are the three simple steps to enable 32 bit Applications in Application Pool of IIS Server.
1. Open Internet Information Services (IIS) Manager and click on Applications Pool from the Left window as shown below.
Could not load file or assembly ‘XYZ’ or one of its dependencies. An attempt was made to load a program with an incorrect format
 
2. Now Right click on the Application Pool for which you want to enable 32 Bit applications and click on Advanced Settings option from the context menu.
Could not load file or assembly ‘XYZ’ or one of its dependencies. An attempt was made to load a program with an incorrect format
 
3. In the Advanced Settings window, look for Enable 32-Bit Applications property, set it to True and click the OK button.
Could not load file or assembly ‘XYZ’ or one of its dependencies. An attempt was made to load a program with an incorrect format