Friday 17 April 2015

could not load file or assembly 'abcd' or one of its dependencies

I faced this problem in my recent project exception was

could not load file or assembly 'abcd' or one of its dependencies. an attempt was made to load a program with an incorrect format.

BadImageFormatException was unhandled:
Could not load file or assembly 'ProjectA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.



I found out the solution which is not related to the code but it is because, of the assembly or dll.
My project was built in 64-bit but we had included a dll which was built on 32-bit.

Therefore, this exception occured to overcome this problem need changes in iis.

Step  -> 1
In IIS > select your pool refer below screen shots



Step -> 2
Select your application pool and right click -> select advanced settings 



Step -> 3 
Change the Enable 32 Bit Applications to True
Step -> 4
Restart IIS and check 

I hope it'll help others who are facing this same issue.

If you find any others solutions, please post here. 

---- Thank you