共用方式為


/platform (C# Compiler Options)

Specifies which version of the common language runtime (CLR) can run the assembly.

/platform:string

Parameters

  • string
    anycpu (default), anycpu32bitpreferred, ARM, x64, x86, or Itanium.

Remarks

  • anycpu (default) compiles your assembly to run on any platform. Your application runs as a 64-bit process whenever possible and falls back to 32-bit when only that mode is available.

  • anycpu32bitpreferred compiles your assembly to run on any platform. Your application runs in 32-bit mode on systems that support both 64-bit and 32-bit applications. You can specify this option only for projects that target the .NET Framework 4.5.

  • ARM compiles your assembly to run on a computer that has an Advanced RISC Machine (ARM) processor.

  • x64 compiles your assembly to be run by the 64-bit common language runtime on a computer that supports the AMD64 or EM64T instruction set.

  • x86 compiles your assembly to be run by the 32-bit, x86-compatible common language runtime.

  • Itanium compiles your assembly to be run by the 64-bit common language runtime on a computer with an Itanium processor.

On a 64-bit Windows operating system:

  • Assemblies compiled with /platform:x86 execute on the 32-bit CLR running under WOW64.

  • A DLL compiled with the /platform:anycpu executes on the same CLR as the process into which it is loaded.

  • Executables that are compiled with the /platform:anycpu execute on the 64-bit CLR.

  • Executables compiled with /platform:anycpu32bitpreferred execute on the 32-bit CLR.

The anycpu32bitpreferred setting is valid only for executable (.EXE) files, and it requires the .NET Framework 4.5.

For more information about developing an application to run on a Windows 64-bit operating system, see 64-bit Applications.

To set this compiler option in the Visual Studio development environment

  1. Open the Properties page for the project.

  2. Click the Build property page.

  3. Modify the Platform target property and, for projects that target the .NET Framework 4.5, select or clear the Prefer 32-bit check box.

Note   /platform is not available in the development environment in Visual C# Express.

For information on how to set this compiler option programmatically, see PlatformTarget.

Example

The following example shows how to use the /platform option to specify that the application should be run by the 64-bit CLR on a 64-bit Windows operating system.

csc /platform:anycpu filename.cs

See Also

Tasks

How to: Modify Project Properties and Configuration Settings

Other Resources

C# Compiler Options