SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)
How do I force a C# project to use x86 in Visual C# 2008 express?
Requested and Answered by Vanna on 04-Feb-2011 16:50 (4222 reads)
It is sometimes required to force a C# application to run in 32 bit emulator (wow64) when it is deployed to 64bit machines.
If you have professional edition of Visual Studio, you will be able to simply change the target platform architecture setting to x86 in a combobox, and you are done.
Unfortunately, this option is not available in the free edition of Visual C# 2008 express. There is however a workaround for this:
1.Close your C# project if it is open.
2.Launch windows explorer, and navigate to your .csproj file. Right click and choose Edit, so that it opens it in a notepad or text editor.
3.You will notice that there are three sections for PropertyGroup. Paste the following entry into each section:
eg.,
(Don't worry about "AnyCPU" text in the project file, it is just a name of the setting)
4. After changing the .csproj file, save an open it in Visual C# express . Do a rebuild all. The new build should be x86.
VERIFY x86 TARGET (Optional)
To verify that it is indeed built for x86, do this:
1.Open Visual studio command prompt.
2.Enter corflags and then check 32BIT output
eg.,
If the 32BIT flag is 1, the target is x86. (If you run this on your earlier build, 32BIT will be 0 - which indicates AnyCPU)
If you have professional edition of Visual Studio, you will be able to simply change the target platform architecture setting to x86 in a combobox, and you are done.
Unfortunately, this option is not available in the free edition of Visual C# 2008 express. There is however a workaround for this:
1.Close your C# project if it is open.
2.Launch windows explorer, and navigate to your .csproj file. Right click and choose Edit, so that it opens it in a notepad or text editor.
3.You will notice that there are three sections for PropertyGroup. Paste the following entry into each section:
<PlatformTarget>x86</PlatformTarget>
eg.,
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4C2EDBD5-0391-42CB-B6A8-DE212E83F330}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>tradtest</RootNamespace>
<PlatformTarget>x86</PlatformTarget>
<AssemblyName>tradtest1</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
(Don't worry about "AnyCPU" text in the project file, it is just a name of the setting)
4. After changing the .csproj file, save an open it in Visual C# express . Do a rebuild all. The new build should be x86.
VERIFY x86 TARGET (Optional)
To verify that it is indeed built for x86, do this:
1.Open Visual studio command prompt.
2.Enter corflags
eg.,
C:\Program Files\Microsoft Visual Studio 8\VC>corflags C:\downloads\tradtest1.o
d\tradtest1\tradtest1\bin\Debug\tradtest1.exe
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 1
ILONLY : 1
32BIT : 1
Signed : 0
If the 32BIT flag is 1, the target is x86. (If you run this on your earlier build, 32BIT will be 0 - which indicates AnyCPU)
Discuss or give feedback? Just enter your message and click on submit. No registration is required.
Discuss or give feedback? Just enter your message and click on submit. No registration is required.

