Could not load file or assembly 'System.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format.
This problem seems to occur rather a lot and it seems there are different causes for it to occur. I have had this problem today and the information I found on the internet did not help at all. I have tried setting System.Data to not copy local, but then it just started with other libraries. I have also changed the .net version in my web.config, but that did not solve my problem either.
The only real difference that I could find between the old and new server was the fact that the new server was 64-bits. So looked into that and found an option in the advanced settings of an app pool in IIS7, named "Enable 32-Bit Applications".
After setting it to true, everything worked as before.
Note: If you want to use this in IIS6, please be aware that IIS6 does not support this on a "per app pool" basis. So if you set IIS6 to 32 bit, all its app pools will run in 32 bit mode. If you want to set this on a "per app pool" basis, you will have to upgrade to IIS7.
To set IIS6 to 32 bit, do the following:
1. Open a command prompt and navigate to the
2. Enter the following command:
cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 "true"
It seems that in some cases, the
"true"from the above command needs to be replaced with a
1. Sometimes it is also necessary to reset IIS.