32位项目和64位项目的一个解决方案是什么? [英] One solution on both 32 bit project and 64bit project working?

查看:141
本文介绍了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位项目的一个解决方案是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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