Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting 32-bit x86 build target in Visual C# 2008 Express Edition?

I'm building a C# application that loads a 32-bit COM dll. The compiled application runs fine on 32-bit Windows but barfs on 64 bit Windows because it can't load the 32-bit COM. Is there a way to set a 32-bit build target in VC# 2008 Express Edition?

Alternatively, is there a way to force a .NET application compiled to the AnyCPU build target to run in 32-bit mode on 64-bit Windows?

like image 996
John Douthat Avatar asked Sep 04 '09 23:09

John Douthat


People also ask

How do I set Build target in Visual Studio?

You can specify a target platform for a Visual Studio* solution or an individual project within a solution. Select a solution or project in Solution Explorer. Select Build > Configuration Manager. Use the Active solution platform drop-down list to specify the target platform for the whole solution.

How do I change a platform target from x86 to a CPU?

Select x86 in the Copy settings from drop-down list box. Click OK. In the Configuration Manager dialog, be sure the box in the Build column is checked for all projects in the solution. Click Close.

How do I change from x86 to x64 in Visual Studio?

To configure a project to target a different platformOn the menu bar, choose Build > Configuration Manager. In the Active solution platform list, choose a platform for the solution to target, and then choose the Close button.

How do I add x86 to Visual Studio?

Click TOOLS > SETTINGS > check EXPERT SETTINGS to see the build configuration manager (This is only applicable to Visual Studio 2010 Express Edition and NOT for 2008 Express Edition) Click BUILD > CONFIGURATION MANAGER select the platform dropdown to X86 and click CLOSE.


1 Answers

For posterity, here is the forum post adrian linked to:

In VC# Express, this property is missing, but you can still create an x86 configuration if you know where to look.

It looks like a long list of steps, but once you know where these things are it's a lot easier. Anyone who only has VC# Express will probably find this useful. Once you know about Configuration Manager, it'll be much more intuitive the next time.

  1. In VC# Express 2005, go to Tools -> Options.
  2. In the bottom-left corner of the Options dialog, check the box that says, "Show all settings".
  3. In the tree-view on the left hand side, select "Projects and Solutions".
  4. In the options on the right, check the box that says, "Show advanced build configuraions."
  5. Click OK.
  6. Go to Build -> Configuration Manager...
  7. In the Platform column next to your project, click the combobox and select "".
  8. In the "New platform" setting, choose "x86".
  9. Click OK.
  10. Click Close.

There, now you have an x86 configuration! Easy as pie! :-)

I also recommend using Configuration Manager to delete the Any CPU platform. You really don't want that if you ever have depedencies on 32-bit native DLLs (even indirect dependencies).

like image 105
John Douthat Avatar answered Oct 26 '22 14:10

John Douthat