C# 开发中可能存在的 64 位操作系统问题 [英] Possible 64-bit operating system issues in C# development

查看:26
本文介绍了C# 开发中可能存在的 64 位操作系统问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的操作系统更新到 Windows 7 x64,我只有运行 32 位操作系统的经验.有人对 64 位环境有什么不好/好的体验吗?

I'm updating my operating system to Windows 7 x64, I only have experience with running 32-bit operating systems. Does anyone have any bad/good experiences with a 64 bit environment?

作为参考,我使用的工具是:

For reference, the tools I use are:

推荐答案

在 64 位操作系统上运行有许多副作用,在某种程度上会很明显.最常见的问题:

Running on a 64-bit operating system has a number of side effects that will be noticeable to some extent. The most common issues:

  • 在 Visual Studio 中编辑并继续不起作用.您可以通过强制您的 .NET 应用程序在 32 位模式下运行来解决此问题.项目 + 属性,构建选项卡,平台目标 = x86.已在 VS2013 中解决.

  • Edit and Continue in Visual Studio won't work. You can fix this by forcing your .NET app to run in 32-bit mode. Project + Properties, Build tab, Platform Target = x86. Resolved in VS2013.

如果您在 .NET 应用程序中使用任何 ActiveX 控件或 COM 组件,您可能会发现您的程序不再运行,因为您的计算机没有相应的 64 位版本的 COM 服务器.您将收到错误 0x80040154,REGDB_E_CLASSNOTREG,类未注册".与上述相同的修复.

If you use any ActiveX controls or COM components in your .NET app you may find your program no longer works since your machine doesn't have a corresponding 64-bit version of the COM server. You'll get error 0x80040154, REGDB_E_CLASSNOTREG, "Class not registered". Same fix as above.

64 位调试器不支持混合模式调试,您必须提交仅托管或仅本机调试.与上述相同的修复,只要您没有 64 位特定问题.已在 VS2010 中解决.

The 64-bit debugger doesn't support mixed-mode debugging, you'll have to commit to either Managed only or Native only debugging. Same fix as above, as long as you don't have 64-bit specific issues. Resolved in VS2010.

在需要 IntPtr 的地方声明 uint 或 int 的 P/Invoke 声明写得不好,将在 64 位模式下停止工作.您通常会收到 AccessViolation 异常或失败返回代码.或 PInvokeStackImbalance MDA 警告.定位错误应该不会有任何问题,只需修复声明即可.

Poorly written P/Invoke declarations that declare an uint or int where an IntPtr is required will stop working in 64-bit mode. You'll generally get an AccessViolation exception or a failure return code. Or a PInvokeStackImbalance MDA warning. You should not have any trouble locating the mistake, just fix the declaration.

一些已停产的旧版 Microsoft 库在 64 位版本中不可用.这是 Microsoft Access 数据库最常见的问题.与上述相同的修复.

Several legacy end-of-life Microsoft libraries are not available in a 64-bit version. That's most commonly a problem with Microsoft Access databases. Same fix as above.

您必须使用正确版本的 Regasm.exe 来注册 [ComVisible] 程序集.根据客户端程序将在 64 位还是 32 位模式下运行,从 Framework 或 Framework64 中选择一个.或者,如果您希望服务器在任一中可用,则两者都可用.

You must use the correct version of Regasm.exe to register [ComVisible] assemblies. Select the one from either Framework or Framework64, depending on whether the client program is going to run in 64-bit or 32-bit mode. Or both if you want the server to be available in either.

一些 COM 类型库在其方法声明中包含与位相关的参数.ADO 2.8 是一个值得注意的版本.请务必使用 Tlbimp.exe 的正确位数来生成正确的 COM 互操作程序集,Visual Studio 不会正确执行此操作.与 Regasm.exe 相同的方法

A few COM type libraries contain bit-ness dependent arguments in their method declarations. ADO 2.8 is a notable one. Be sure to use the correct bitness of Tlbimp.exe to generate the correct COM interop assembly, Visual Studio won't do this right. Same approach as Regasm.exe

32 位程序与 64 位程序具有不同的注册表视图.特别是 HKCR 和 HKLMSoftware 配置单元是虚拟化的.在 Regedit.exe 中,32 位可见键位于 HKLMSoftwareWow6432Node 键下.这可能会导致使用注册表的程序出现许多微妙的问题..NET 4 RegistryKey.OpenBaseKey() 允许指定您想要的视图.

A 32-bit program has a different view of the registry from a 64-bit program. Specifically the HKCR and HKLMSoftware hives are virtualized. In Regedit.exe, the 32-bit visible keys are seen under the HKLMSoftwareWow6432Node key. This can cause many subtle problems with programs that use the registry. The .NET 4 RegistryKey.OpenBaseKey() allows specifying the view you want.

同样对于 COM,您将使用正确的 Regsvr32.exe 位数来注册非托管 COM 服务器(不是 .NET 服务器,它们使用 Regasm.exe).对于 64 位服务器使用 c:windowssystem32 中的一个,对于 32 位服务器使用 c:windowssyswow64.

Again for COM, you'll have the use the correct bitness of Regsvr32.exe to register an unmanaged COM server (not .NET servers, they use Regasm.exe). Use the one in c:windowssystem32 for 64-bit servers, c:windowssyswow64 for 32-bit servers.

文件系统中的文件夹是虚拟化的,特别是 c:windowssystem32 和 c:program 文件.32 位程序将看到 c:windowssyswow64 和 c:program 文件 (x86).

Folders in the file system are virtualized, specifically c:windowssystem32 and c:program files. A 32-bit program will see c:windowssyswow64 and c:program files (x86).

安装人员需要考虑以上所有问题.

Installers need to take all the above issues in consideration.

这篇关于C# 开发中可能存在的 64 位操作系统问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆