32至64位。NET(4)应用的差异 [英] Differences between 32 and 64-bit .NET (4) applications

查看:137
本文介绍了32至64位。NET(4)应用的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是32至64位。NET(4)应用程序的区别是什么?

What are the differences between 32 and 64-bit .NET (4) applications?

通常的32位应用程序必须在64位机器上运行,相反的问题。我知道我可以声明整数INT32和Int64的(在32位系统肯定的Int64使问题)。是一个32位或64位或32位和64位兼容的应用程序?编程之间有其他方面的差异

Often 32-bit applications have problems running on 64-bit machines and conversely. I know I can declare an integer as int32 and int64 (certainly int64 on 32-bit systems make problems). Are there other differences between programming an 32 OR 64-bit or a both 32 AND 64-bit compatible application?

推荐答案

一些差异:

  1. 32位和64位应用程序只能加载相同位数的DLL文件。这可能是一个问题管理的项目,如果你的平台的目标是任何CPU和您引用或的P / Invoke 的32位原生的DLL。当你的任何CPU的程序在64位机上运行,​​因为您的应用程序作为64位进程运行的问题就出现了。当它尝试加载32位本机DLL的依赖,它会抛出一个异常(<一href="http://msdn.microsoft.com/en-us/library/system.badimageformatexception.aspx"><$c$c>BadImageFormatException)并有可能崩溃。

  1. 32-bit and 64-bit applications can only load DLLs of the same bitness. This can be an issue for managed projects if your platform target is "Any CPU" and you reference or P/Invoke 32-bit native DLLs. The issue arises when your "Any CPU" program runs on a 64-bit machine, since your application runs as a 64-bit process. When it tries to load the 32-bit native DLL dependency, it will throw an exception (BadImageFormatException) and likely crash.

另外还有文件系统和注册表的问题。一个 WOW64 进程尝试读取 C:\ Program Files文件最终会得到重定向到 C:\ Program Files文件(x86)的,除非它先禁用的Windows文件系统重定向(p <一个href="http://msdn.microsoft.com/en-us/library/aa365743%28VS.85%29.aspx"><$c$c>Wow64DisableWow64FsRedirection).对于Windows中的Windows 7之前的版本,也有在类似于上面提到的文件系统重定向问题注册表反射的问题。MSDN文章的注册表反射 的解释很清楚。

There are also filesystem and registry issues. A WOW64 process that tries to read from C:\Program Files will end up getting redirected to C:\Program Files (x86) unless it first disables Windows filesystem redirection (see Wow64DisableWow64FsRedirection). For versions of Windows before Windows 7, there were also registry reflection issues that were similar to the filesystem redirection issues mentioned above. The MSDN article Registry Reflection explains it well.

特定于平台如的IntPtr 类型具有不同的尺寸。这可能是在code一个问题,假定一个固定大小(序列化,编组)。

Platform-specific types like IntPtr will have different sizes. This could be an issue in code that assumes a fixed size (serialization, marshaling).

有在 GAC 中的32位和64位的文件单独的物理目录。对于我的系统,他们是在 C:\ WINDOWS \ Microsoft.NET \组装\ GAC_32 C:\ WINDOWS \ Microsoft.NET \组装\ GAC_64

There are separate physical directories for the 32- and 64-bit files in the GAC. For my system, they are at C:\Windows\Microsoft.NET\assembly\GAC_32 and C:\Windows\Microsoft.NET\assembly\GAC_64.

的32位和64位应用程序的虚拟地址空间的大小是不同的。对于32位应用程序的大小可以是2&NBSP; GB(默认)或3&NBSP; GB(用的 4GT 的启用)。对于64位应用程序,大小为8&NBSP; TB。 32位的地址空间可以是非常大的应用程序的限制。

The virtual address space size of 32- and 64-bit applications is different. For 32-bit applications, the size is either 2 GB (default) or 3 GB (with 4GT enabled). For 64-bit applications, the size is 8 TB. The 32-bit address space can be a limitation for very large applications.

一个有点晦涩难懂,但很多间的Win32 通话将不是32之间工作和64位进程。例如,一个32位的过程中可以尝试调用<一个失败时href="http://msdn.microsoft.com/en-us/library/ms680553%28VS.85%29.aspx"><$c$c>ReadProcessMemory在64位进程。这同样适用于 WriteProcessMemory的 EnumProcessModules ,和很多类似的方法。这可以在C#应用程序中可以看出,如果你试图使用从32位应用程序枚举64位应用程序的模块的<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.modules.aspx"><$c$c>System.Diagnostics.Process.Modules API。

A little more obscure, but a lot of interprocess Win32 calls won't work between a 32- and 64-bit process. For example, a 32-bit process can fail when trying to call ReadProcessMemory on a 64-bit process. The same goes for WriteProcessMemory, EnumProcessModules, and a lot of similar methods. This can be seen in C# applications if you try to enumerate the modules of a 64-bit application from a 32-bit application using the System.Diagnostics.Process.Modules API.

这篇关于32至64位。NET(4)应用的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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