C# – Accessing an XML embeded resource file throws error in Release mode but not Debug mode

cnetresourcesvisual-studio-2008

.NET 3.5
Visual Studio 2008 Team Edition

I have an XML file that I've added to an assembly via the Resources tab of the project's properties; and have marked the Access Modifier as public. While running in debug mode, there are no problems referencing the assembly and the embedded resource in another project, i.e.,

XElement errorMap = XElement.Parse( Properties.Resources.ErrorMapper );

However, when the projects are run in Release mode, I receive this error:

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

Why would the projects run fine in Debug mode but not Release mode?

Best Answer

Hmmm....

I run a 64 bit dev machine and had targeted the build and release modes to the x86 platform. Apparently, when I added the resource file the platform build for release mode changed to Any CPU.

Since I reference some 3rd party DLL's that require 32 bit, the Any CPU build on Release mode puked out.

Problem solved.