64 到 32 位互操作 - 如何? [英] 64 to 32 bit Interop - how?
问题描述
我需要将一些遗留的 32 位代码(我没有源代码)集成到一个项目中,以便可以从 64 位 .NET 程序集调用它.原始代码在 DLL 中实现为 32 位 COM 对象.Windows 不允许从 64 位对象直接调用到 32 位对象,因此我正在寻找有关如何处理这种情况的灵感.
I need to integrate some legacy 32-bit code - for which I don't have the source code, into a project in such a way that it can be called from a 64-bit .NET assembly. The original code is implemented as a 32-bit COM object in a DLL. Windows doesn't allow direct calls from 64 to 32-bit objects, so I'm looking for inspiration on how to deal with this situation.
如何从 64 位 .NET 程序集访问旧的 32 位 COM 对象?
How can a legacy 32-bit COM object be accessed from a 64-bit .NET assembly?
更新:我们发现 COM 组件本身是一些 ANSI C 的包装器,我们找到了它的原始来源.我们能够在 Visual Studio 中将其编译为本机 64 位 dll,并将其导入到 .NET 中 - 很抱歉移动了目标!
UPDATE: We discovered that the COM component was itself a wrapper around some ANSI C, which we founf the original source for. We were able to compile that in Visual Studio as a native 64-bit dll, and import that into .NET - sorry to move the goalposts!
推荐答案
最好的方法是制作一个封装 32 位 DLL 的进程外 COM 服务器.然后您可以从 64 位代码调用它.
The best approach is to make an out of process COM server that wraps your 32-bit DLL. You can then call this from 64bit code.
这篇关于64 到 32 位互操作 - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!