可以在x64应用程序中使用的x86组件 - 反之亦然? [英] Can an x64 application use x86 assemblies - and vice versa?

查看:316
本文介绍了可以在x64应用程序中使用的x86组件 - 反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序构建为64位应用程序。移动到VS2010后,我得到了<一href="http://stackoverflow.com/questions/2688993/problem-with-sqlite-related-nunit-tests-after-upgrade-to-vs2010-and-re5">some 的问题,这似乎是与中引用的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.

我的问题是:precautions做我需要有关混合x64和x86。可它在所有做什么?我想64的应用程序应该能够使用x86的dll文件没有问题。没有?那么其他的方式?可一个86应用程序中引用的64 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位的64位版本的Windows)。这问题是,如果你在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中,他们拖欠的所有可执行的项目是86(即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组件 - 反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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