C# 开发中可能出现的 64 位操作系统问题

Possible 64-bit operating system issues in C# development(C# 开发中可能出现的 64 位操作系统问题)
本文介绍了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:

  • Visual Studio 2008
  • 乌龟SVN
  • TestDriven.Net
  • Oracle 10g XE
  • PL/SQL Developer
  • 邓达斯图
  • MS SQL Server 2008 的分析服务

推荐答案

在 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 位操作系统问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)