In my solution I am importing external projects which I use as references. After coding and setting Release x64 (in Standard toolbox) I got a problem with build. The problem is for sure related to x64/x86 configuration. When I go to properties of the solution and projects as well, all of them are set to x64 except my project. Finally, the problem is that I can't choose x64. Has anyone faced with this kind of problem? The error message is:
Could not load file or assembly … An attempt was made to load a program with an incorrect format (System.BadImageFormatException)
The preview is also here...
The solution platform option turned into a huge mess when Microsoft started tinkering with the default selection for C# projects in VS2010. It always used to be AnyCPU, accurately reflecting the ability of managed projects to run on any processor. In VS2010 they changed the default to x86. That created massive amounts of problems, they switched back to AnyCPU in VS2012 and up.
The best thing to do is to click the Configuration Manager button and delete all of the extraneous platforms. You are stuck on VS2010 right now so only keep x86 since that is the default for new projects. On any other VS version keep AnyCPU. Just keep a mental note that the name is irrelevant.
The actual bitness of the process is determined by the EXE project, it is the one that starts the process and can force the CLR to use a particular jitter. Right-click the project > Properties > Build tab > Platform target setting. Pick x86 if you need your program to run in 32-bit mode. Otherwise use AnyCPU. All of your library projects should be AnyCPU so they can simply follow the EXE project or unit test selection. Do this both for the Debug and Release configurations.
Fwiw, it does matter whenever you start to create Universal apps in VS2015. No longer jitted, you then need to test the .NET Native compiled version of your app, it pays attention to the solution platform. So for those kind of projects it is important again, you need to keep the x86, x64 and ARM platforms around. Not relevant to this VS2010 question.