大约64位:用Vista 64编写的代码是否在32位操作系统上兼容?

大约64位:用Vista 64编写的代码是否在32位操作系统上兼容?

Is code written in Vista 64 compatible on 32 bit os?

我们将获得新的开发机器,并升级到Vista 64 Ultimate,以利用我们的8GB内存。我们的经理希望我们在32位虚拟机上进行所有开发工作,以确保将代码投入生产不会出现任何问题。

有什么方法可以保证生成的程序可以在32位操作系统上运行?
我不介意使用虚拟机,但是我不喜欢它们如何迫使您返回"单一"监视器类型视图。我喜欢将VS工具栏移到其他显示器上。

编辑:我们正在使用Visual Studio 2005和2008,VB.NET和/或C#

编辑:使用Harpreet的答案,这些是我用来设置Visual Studio IDE来编译x86 / 32bit的步骤:

  • 单击生成并打开配置管理器
  • 选择活动解决方案平台下拉列表
  • 如果在列表中,请选择x86,否则请跳至步骤5。选择>
  • 在"新解决方案平台"对话框中,选择" x86",然后按"确定"。
  • 验证为所有项目选择的平台是x86
  • 单击关闭。
  • 请享用。

    谢谢,
    基思


    我在用于32位Windows的64位计算机上进行开发。这不是一个问题。为了保守起见,应确保将项目设置为以x86模式编译。您将要遍历解决方案中的每个项目,并仔细检查。您也可以使用AnyCPU设置,但是这样做的风险要高一些,因为它在开发机上的运行方式与32位机上的运行方式不同。当然,您要避免使用64位模式。

    我遇到的问题是当应用程序针对64位编译(显式为64位或AnyCPU编译并在64位Windows上运行)时无法使用的驱动程序。坚持使用x86编译可以完全避免这些问题。那应该揭示您开发机器上的所有缺陷。

    理想情况下,您可以设置可以在32位计算机上频繁执行的构建和测试环境。这样可以使您的管理放心,并避免将VM用作桌面。


    只要您将可执行文件编译为32位,它们就可以在32位和64位Windows计算机上运行(保证)。使用64位开发者计算机的优势在于,您可以开始使用64位编译测试代码(以检查指针是否转换为32位整数),这样一来,将来转换到64位的过程将更加轻松(您应由公司选择)做一个64位版本)。


    我们使用VS 2005开发了一个32位应用程序(即将在2008年发布),并且刚刚购买了一些新机器,它们上装有XP Pro x64或Vista Business 64位,以便我们可以利用额外的RAM并同时观看有关如果在商业上需要这样做,则有可能使用64位端口。除了在开发环境中调整一些脚本等之外,我们在此方面没有任何问题。

    那些未包含在此升级周期中的开发人员仍然使用32位计算机,因此在检入之前自然会在单元测试和应用程序测试套件运行时遇到问题。

    我们还要做的是确保我们有一组由"典型"配置(XP / Vista,2/4/8内核等)组成的"测试构建"机器,用于构建和测试签入集-在稳定性,性能等方面,我们有各种不同的测试套件-在将它们添加到适当的集成区域之前。同样,这些都不会对运行基于64位OS的32位应用程序带来任何问题。

    无论如何,就像其他人已经说过的那样,我不希望这是一个问题,因为是由编译器为目标OS生成适当的代码,而不管编译器实际运行于哪个OS上。


    这不是您问题的答案,但可能是您问题的解决方案:VirtualBox(以及可能的其他产品)支持"无缝集成"模式,该模式仅提供第二个开始栏,并允许您自由拖动窗口。

    另外,这是对您问题的答案,这取决于您的编译设置。您可以针对不同的环境进行编译,并且可以使用Visual Studio在64位系统上完美地编译32位程序。无法告诉您如何使用,但是我敢肯定,某些??Visual Studio专家可以帮助您。


    64位操作系统的编译是编译器中的一个选项。您可以从Vista 64位中绝对编译为32位exe。当您运行该应用程序时,您可以在TaskManager中看到该进程旁边有一个" * 32"……这意味着它是32位的;)

    我相信您的经理需要对64位操作系统的真正含义进行更多的了解:)


    今天发现:

    http://www.brianpeek.com/blog/archive/2007/11/13/x64-development-with-net.aspx

    x64 Development with .NET

    Earlier this year I made the switch to a 64-bit operating system - Vista Ultimate x64 to be exact. For the most part, this process has been relatively painless, but there have been a few hiccups along the way (x64 compatible drivers, mainly, but that's not the point of this discussion).

    In the world of x64 development, there have been a few struggling points that I thought I'd outline here. This list will likely grow, so expect future posts on the matter.

    In the wonderful world of .NET development, applications and assemblies can be compiled to target various platforms. By default, applications and assemblies are compiled as Any CPU in Visual Studio. In this scenario, the CLR will load the assembly as whatever the default target is for the machine it is being executed on. For example, when running an executable on an x64 machine, it will be run as a 64-bit process.

    Visual Studio also provides for 3 specific platform targets: x86, x64 and Itanium (IA-64). When building an executable as a specific target, it will be loaded as a process of that type. For example, an x86-targeted executable run on an x64 machine will run as a 32-bit process using the 32-bit CLR and WOW64 layer. When assemblies are loaded at runtime, they can only be loaded by a process if their target matches that of the hosting process, or it is compiled as Any CPU. For example, if x64 were set as the target for an assembly, it can only be loaded by an x64 process.

    This has come into play in a few scenarios for me:

    • XNA - XNA is available as a set of 32-bit assemblies only. Therefore, when referencing the XNA assemblies, the executable/assembly using them must be targeted to the x86 platform. If it is targeted as x64 (or as Any CPU and run on a 64-bit machine), an error will be thrown when trying to load the XNA assemblies.

    • Microsoft Robotics Studio - The XInputGamepadService uses XNA internally to talk to the Xbox 360 controller. See above.

    • Managed DirectX - While this is already deprecated and being replaced with XNA, it still has its uses. The assemblies are not marked for a specific target, however I had difficulty with memory exceptions, especially with the Microsoft.DirectX.AudioVideoPlayback assembly.

    • Phidgets - Depending on what library you download and when, it may or may not be marked as 32-bit only. The current version (11/8/07) is marked as such, and so requires a 32-bit process to host it.
      The easiest way to determine if an executable or assembly is targeted to a specific platform is to use the corflags application. To use this, open a Visual Studio Command Prompt from your Start menu and run it against the assembly you wish to check.

    The easiest way to determine if an executable or assembly is targeted to a specific platform is to use the corflags application. To use this, open a Visual Studio Command Prompt from your Start menu and run it against the assembly you wish to check.


    是的,就像亚当说的那样。有3个选项:MSIL(默认),x64和x86。您可以以x64为目标,并且它将生成专门用于64位系统的dll,或者您可以执行x86,它将在32位和64位系统上运行,但与在64位系统上的32位系统具有相同的限制。

    MSIL将基本上让JITer发出平台特定的指令(与本地映像相比,性能会受到轻微影响)

    编辑:没有语言,所以我说的是.net框架语言,例如vb.net和c#,c ++是一种完全不同的动物。


    推荐阅读