C#for 64bit操作系统?
答
托管项目根据所选体系结构自动构建=>在AMD64上创建的默认C#项目将为X86上的AMD64,X86。本机默认情况下总是32位。
要明确设置了一个平台:
1打开解决方案资源管理器中,选择解决方案,右点击 - >配置管理器。
2转到“Active Solution Platform”,单击“新建”。
3在出现的“新解决方案平台”对话框中选择新的平台,比如Itanium。将'将设置复制'设置为'任何CPU',这是'Active Solution Platform'中的默认设置。
4单击确定。
这是WebLog
答
帕特里克德信表示,与一点点增加。
请注意,如果您有使用Interop的第三方DLL并使用32位编译。在这种情况下,您将专门设置所有使用它的程序集来使用x86或所有奇怪的事情都会发生。
答
您也可能想要做在运行时进行检查,以防万一:
using System;
using System.Runtime.InteropServices;
class SystemChecker
{
static bool Is64Bit
{
get { return Marshal.SizeOf(typeof(IntPtr)) == 8; }
}
}
答
您可以通过/platform
-flag编译64位。请注意,visual studio Express没有直接的64位编译设置。
请参阅here了解更多信息和here。从第二源获取是以下信息:
在64位Windows操作系统:
- 装配体与
/platform:x86
编译将执行上WOW64下32位CLR运行。 - 使用
/platform:anycpu
编译的可执行文件将在64位CLR上执行。 - 使用
/platform:anycpu
编译的DLL将在与其加载的进程相同的CLR上执行。
运行时检查:
您可以通过以下选项
bool is64BitProcess = IntPtr.Size == 8;
int bitProcess = IntPtr.Size*8;
//C# 4 provides System.Environment.Is64BitProcess
//TimothyP's solution:
bool is64BitProcess = Marshal.SizeOf(typeof(IntPtr)) == 8;
一个检查在运行时执行位环境不会与Visual Studio的速成版工作... – 2012-09-17 20:55:14