32位项目和64位项目的一个解决方案是什么?

编程入门 行业动态 更新时间:2024-10-28 10:21:39
本文介绍了32位项目和64位项目的一个解决方案是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在32位项目和64位项目上运行一个Visual C#解决方案? 我尝试了什么: 两个项目都不兼容。没有任何想法

How to One Visual C# solution on both 32bit project and 64bit project working? What I have tried: Not working both projects. There isn't any idea

推荐答案

将项目开发到AnyCPU目标,这是最好的。然后它将适用于任何CPU架构。 严格来说,没有32位项目或64位项目(尤其是64位,因为x86-64和IE64是两种不同的不兼容架构,所以甚至只有64位目标。 指定平台的唯一原因 - 特定目标(不是AnyCPU)可能是您在程序集中使用的某些本机(非托管)模块的使用。即使你使用这样的模块,在许多情况下解决问题而不破坏AnyCPU也是可能的。您可以将此模块用于不同平台的版本,而不是直接使用它。相反,您可以P / Invoke跨平台 LoadLibrary 和 GetProcAddress 并动态加载相应版本的模块,具体取决于在运行时检测到的CPU架构。这项技术非常先进,所以我不想浪费时间进行详细解释,除非你对这个主题有一些合格的后续问题。 它也是很高兴知道WoW64,允许在64位CPU上使用x86模块(32位)用于不同版本的操作系统: WoW64 - 维基百科,免费的百科全书 [ ^ ]。 />
-SA
Develop project to the "AnyCPU" target, this is the best. Then it will work on any CPU architecture. Strictly speaking, there is no such thing as "32-bit project" or "64-bit project" (and especially 64-bit, because x86-64 and IE64 are two different incompatible architectures, so there is even just 64-bit target). The only reason to specify platform-specific target (not "AnyCPU") could be the use of some native (non-managed) module used in you assembly. And even if you use such module, in many cases working around the problem without breaking "AnyCPU" can be possible. You can have this module in version for different platform and not use it directly. Instead, you can P/Invoke cross-platform LoadLibrary and GetProcAddress and dynamically load appropriate version of the module, depending on the CPU architecture detected during runtime. This technique is pretty advanced, so I don't want to waste time for detailed explanation, unless you have some qualified follow-up questions on the topic. It's also good to be aware of WoW64, which allows using x86 modules (32-bit) for different versions of OS on 64-bit CPU: WoW64 — Wikipedia, the free encyclopedia[^].
—SA

您可以使用X86编译代码,它适用于32BIT和64BIT 处理器。 正如SA解释的那样,WOW64在64位机器上支持32位应用程序 You can compile your code with X86 and it works for both 32BIT and 64BIT processors. As SA explained, WOW64 support 32 bit applications on 64bit machines

更多推荐

32位项目和64位项目的一个解决方案是什么?

本文发布于:2023-11-06 22:17:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564821.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   解决方案

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!