I have this project setup for continuous integration with cruise control. It’s been up and running for quite sometime then suddenly the website starts getting the following errors on every successful build.

Exception Details: System.BadImageFormatException: Could not load file or assembly ‘Microsoft.VisualBasic.Activities.Compiler’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

The Error Page
Solution/Project Platform Target Configuration + Cruise Build

I did not make any changes to the build configs at all and the site runs fine locally. There is no reference to ‘Microsoft.VisualBasic.Activities.Compiler‘ in my project and it doesn’t have VB code. I found some extra files, see below list, in the deployment bin while comparing the bin assemblies on deployment server and my local. Once remove those files, the site comes back on, but the files are added with every cruise build.

  • Microsoft.VisualBasic.Activities.Compiler.dll
  • Microsoft.Practices.ServiceLocation.dll
  • Microsoft.Practices.ServiceLocation.xml
  • mscorlib.dll
  • normidna.nlp
  • normnfc.nlp
  • normnfd.nlp
  • normnfkc.nlp
  • normnfkd.nlp
  • PresentationCore.dll
  • System.Data.dll
  • System.Data.OracleClient.dll
  • System.EnterpriseServices.dll
  • System.EnterpriseServices.Wrapper.dll
  • System.Printing.dll
  • System.Transactions.dll

I google a bit to check similar problems out there and found only one link, which was fixed by installing missing SDK or something. I didn’t think that was the right solution for me but got an idea to check for target platform configuration on the solution and project files.

I compare with one of my working project many times using visual studio property window to check for the solution and project file configuration properties but they seemed to be the same, using ANYCPU for the build platform. I didn’t trust the VS property designer so used WinMerge to compare the two files and found that there are some additional configuration lines added to the solution file. So I open the .sln and .csproj in notepad, removed all the extra configs, see the image below, checked back in, forced build the Cruise Control and walah all those craps gone and the site is back to the way it was.

.sln Solution file comparison and the lines to remove
Solution/Project Platform Target Configuration + Cruise Build

.csproj Project file comparison and the line to remove
Solution/Project Platform Target Configuration + Cruise Build

The point I like to make here is that although no error with cruise build, your site can still be broken and freaking Visual Studio design views lie many time so remember to go for the good old way of editing it in notepad.

Note: If you don’t have any working version to compare, just search for “Mixed Platforms” or “x86” in .sln file and “<PlatformTarget>AnyCPU</PlatformTarget>” in .csproj file and remove them accordingly.