At my job I work on an internal line-of-business Silverlight/RIA Services application. After switching to a new branch in TFS (and doing some necessary library updates for the new branch) I started getting the following error when I built the Silverlight project:
Error 16 The “CreateRiaClientFilesTask” task failed unexpectedly.
System.Web.HttpException (0x80004005): Could not load file or assembly ‘ILCentral.Web’ or one of its dependencies. An attempt was made to load a program with an incorrect format. —> System.Configuration.ConfigurationErrorsException: Could not load file or assembly ‘ILCentral.Web’ or one of its dependencies. An attempt was made to load a program with an incorrect format. —> System.BadImageFormatException: Could not load file or assembly ‘ILCentral.Web’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
After searching all over for any permutation of main error message, I stumbled across this thread on the Silverlight forum. The gist of the problem (as far as I understand) is loading a 64-bit library (i.e. native or unmanaged code). I sifted through my assembly references, looked at the projects I was importing from our main codebase, but to no avail. Eventually I remembered that library I had to update when I relocated to the new branch, PostSharp. In the main codebase, we use PostSharp to wrap our db calls in transactions. I’d never played with it much, and the extent of my experience with it was installing it and occasionally killing the process the get the build to work.
So, the solution: PostSharp was being loaded during the CreateRiaClientFilesTask because it’s on by default. Note that the library is not used in production code, just for compile time magic. Lucky for me, I didn’t need PostSharp, so I turned it off for my project.
Hopefully this post helps the next unfortunate soul that runs across this wonderful feature of RIA Services.