views:

4953

answers:

3

I have a strange problem, and hopefully someone can help me.

I have a solution with 13 separate C# projects. I am using Vista x64 to develop on, and I would like to build these projects to target the x86 platform. This is normally quite easy. I can go to solution properties -> Configuration properties and change the platform to x86. The strange part here is that 3 of my projects refuse to allow me to select x86.

So, I thought I'd go to each of these 3 projects separately and change it in Project Properties->Build and change the Platform. And the Configuration and Platform dropdowns are not there for these projects. I googled around a bit, and found a setting in Tools->Options->Projects And Solutions->Show Advanced build configuration. After selecting this, when going to Project Properties for the offending projects, I now see both dropdowns, but the platform only lets me select Active (Any CPU).

I can also not change the Platform in Solution properties to x86 for these projects.

Any ideas?

A: 

I would compare the textual contents of the csproj files to see if there is any setting that has fallen out or in by accident. Also check the contents of the sln, maybe there's something weird with the configs.

Regards,

Sebastiaan

Sebastiaan Megens
Thanks for the response. I did spend some time doing this, and went as far as creating a new project and copying the source files from one into the new one. The new project worked as it should. The prospect of changing one of the larger projects though was daunting to say the least...
tardomatic
+1  A: 

I also develop on x64 and deploy to x86. However I don't change the platform from the default value (Any CPU) and it works for me just fine. Do you have any code (such as Win interop) that works differently across platforms? Check out this post by Hanselman for details on 32/64 bit .NET targeting.

zvolkov
Hi, thanks for the response. Unfortunately, I do need to interact with 32bit interops, hence the need to compile to x86. I think there may be a problem with the link you provided though. I'd be interested to read it.
tardomatic
Fixed the link. Don't forget to upvote :)
zvolkov
Excellent read, thanks for the link. Bookmarked.
tardomatic
+3  A: 

Sounds like the Build Configurations have gone screwy. The three projects were probably added after the solution was configured to have x86 support (New projects only support AnyCPU, even if the solution supports more platforms.)

  • Go Build->Configuration Manager...
  • Change 'Active Solution Platform' to x86 (if it's there. If only AnyCPU is there, then use that.)
  • For each offending project, in the Platform column, select 'New'
  • Choose New Platform as 'x86', Copy Settings from 'Any CPU', and make sure the check box is NOT ticked.
  • Hit OK.

Getting configuration/platforms consistent between the solution and individual projects can be tricky. The Configuration Manager can behave unexpectedly - especially with custom solution configurations. I suggest playing in a test solution first.

Dave
This works for me. Thanks very much for your help.
tardomatic