Training
Module
Choose the correct data type in your C# code - Training
Choose the correct data type for your code from several basic types used in C#.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When you compile an application, you can specify that it should run on a Windows 64-bit operating system either as a native application or under WOW64 (Windows 32-bit on Windows 64-bit). WOW64 is a compatibility environment that enables a 32-bit application to run on a 64-bit system. WOW64 is included in all 64-bit versions of the Windows operating system.
32-bit applications that are built on .NET Framework 4 or later versions run under WOW64 on 64-bit systems.
Note
Because of the design of x86 emulation and the WOW64 subsystem for the Itanium processor family, applications are restricted to execution on one processor. These factors reduce the performance and scalability of 32-bit .NET applications that run on Itanium-based systems. We recommend that you use .NET Framework 4 or later, which includes native 64-bit support for Itanium-based systems, for increased performance and scalability.
By default, when you run a 64-bit managed application on a 64-bit Windows operating system, you can create an object of no more than 2 gigabytes (GB). However, in .NET Framework 4.5 and later, you can increase this limit. For more information, see the <gcAllowVeryLargeObjects> element.
Many assemblies run identically on both the 32-bit CLR and the 64-bit CLR. However, some programs may behave differently, depending on the CLR, if they contain one or more of the following:
Int32
for handles instead of IntPtr
.IntPtr
to Int32
.For more information about how to port a 32-bit application to run on the 64-bit CLR, see Migrating 32-bit Managed Code to 64-bit.
For general information about 64-bit programming, see the following documents:
By default, when you use .NET to build an application on either a 32-bit or a 64-bit computer, the application will run on a 64-bit computer as a native application (that is, not under WOW64). The following table lists documents that explain how to use Visual Studio compilers to create 64-bit applications that will run as native, under WOW64, or both.
Compiler | Compiler option |
---|---|
Visual Basic | -platform (Visual Basic) |
Visual C# | -platform (C# Compiler Options) |
Visual C++ | You can create platform-agnostic, common intermediate language (CIL) applications by using /clr:safe. For more information, see -clr (Common Language Runtime Compilation). Visual C++ includes a separate compiler for each 64-bit operating system. For more information about how to use Visual C++ to create native applications that run on a 64-bit Windows operating system, see 64-bit Programming. |
To determine whether an .exe file or .dll file is meant to run only on a specific platform or under WOW64, use CorFlags.exe (CorFlags Conversion Tool) with no options. You can also use CorFlags.exe to change the platform status of an .exe file or .dll file. The CLR header of a Visual Studio assembly has the major runtime version number set to 2 and the minor runtime version number set to 5. Applications that have the minor runtime version set to 0 are treated as legacy applications and are always executed under WOW64.
To programmatically query an .exe or .dll to see whether it is meant to run only on a specific platform or under WOW64, use the Module.GetPEKind method.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Choose the correct data type in your C# code - Training
Choose the correct data type for your code from several basic types used in C#.