x64应用程序可以使用x86程序集吗?反之亦然

编程入门 行业动态 更新时间:2024-10-27 19:18:09
本文介绍了x64应用程序可以使用x86程序集吗?反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的应用程序是作为x64应用程序构建的。搬到VS2010后,我获得了一些问题这似乎与引用的dll中的一些x64 / x86不匹配有关。现在我正在移动目标.NET4,并且我获得更多的类似的问题。

My application is built as a x64 application. After moving to VS2010 I got some problems which seems to be related to some x64/x86 mismatch in referenced dlls. Now I'm moving to target .NET4, and I get even more similar problems.

我的问题是:在混合x64和x86时需要采取什么预防措施。可以完成吗?我认为x64应用程序应该能够使用x86 dll没有问题。没有?另一方面呢?一个x86应用程序可以引用x64 dll - 只要它在x64平台上运行?我需要注意什么陷阱?

My question is: What precautions do I need to take regarding mixing x64 and x86. Can it be done at all? I thought x64 applications should be able to use x86 dlls without problems. No? What about the other way? Can a x86 application reference an x64 dll - as long as it is being run on an x64 platform? What are the pitfalls I need to be aware of?

推荐答案

不,64位进程只能加载64位DLL,32位进程只能加载32-位DLL。您可能会想到的是,64位操作系统可以运行32位进程。

No, a 64-bit process can only load 64-bit DLLs and a 32-bit process can only load 32-bit DLLs. What you're probably thinking of is that a 64-bit operating system can run 32-bit processes.

.NET的主要问题是 - 在VS2010之前 - 可执行项目默认为AnyCPU,这意味着它将以正在运行的操作系统的本机格式加载(因此32位32位版本的Windows 64位版本的Windows 64位)。问题在于,如果您在32位Windows上测试了应用程序(比如说),那么如果您加载了32位DLL并尝试在64位Windows上运行,那么可能会损坏。

The main issue with .NET is that - prior to VS2010 - executable projects defaulted to "AnyCPU" which means it would load in the "native" format of the OS it's running on (so 32-bit for 32-bit versions of Windows and 64-bit for 64-bit versions of Windows). The problem with that is that if you tested your application on 32-bit Windows (say) then it could break if you load 32-bit DLLs and tried to run on 64-bit Windows.

在VS2010中,默认情况下,所有可执行项目默认为x86(即32位),这大部分可以减轻问题。

In VS2010, they defaulted all executable projects to be "x86" (that is, 32-bit) by default which (for the most part) mitigates the problem.

更多推荐

x64应用程序可以使用x86程序集吗?反之亦然

本文发布于:2023-10-07 15:51:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469821.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   应用程序   程序

发布评论

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

>www.elefans.com

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