如何在64位应用程序中使用32位dll? [英] How do I use 32-bit dll in 64-bit app?

查看:1527
本文介绍了如何在64位应用程序中使用32位dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,我想制作64位,但是我有一个仅在编译32位时才起作用的库dll.

除了拥有两个单独的可执行文件之外,还有其他方法吗?

我认为这无关紧要,但是出于完整性考虑,有问题的dll是Interop.MRTKTASKLib.dll.

我收到的异常消息是为具有CLSID的组件检索COM类工厂...由于以下错误而失败:80040154."

谢谢.

I have a C# application that I''d like to make 64-bit but I have a library dll that only works when I compile 32-bit.

Is there any other way than having two separate executables to achieve this?

I don''t think it should matter, but for completeness the dll in question is Interop.MRTKTASKLib.dll.

The Exception message I get is "Retrieving the COM class factory for component with CLSID ... failed due to the following error: 80040154."

Thanks.

推荐答案

不是直接不.

可能有一种解决方法从以下位置访问32位DLL: 64位代码 [
Not directly no.

There might be a workaround Accessing 32-bit DLLs from 64-bit code[^], but it comes with a lot of strings attached.

You might have to re-evaluate your reasons for wanting to convert to 64-bit.


感谢所有答复.根据答案,我想如果我看了足够长的时间,就会发现一些能让我轻松连接的东西.

我找到了.

它涉及注册表.


1.在HKey_Classes_Root/Wow6432Node/CLSID
下找到您的COM对象GUID.
2.找到后,添加新的REG_SZ(字符串)值.名称应为AppID,数据应与您刚刚搜索的相同的COM对象GUID

3.在HKey_Classes_Root/Wow6432Node/AppID下添加一个新密钥.新密钥的调用应与com对象GUID相同.
4.在刚添加的新键下,添加一个新的REG_SZ(字符串)值,并将其命名为DllSurrogate.将该值留空

5.如果尚不存在,请在HKey_Local_Machine/SoftwareClasses/AppID下创建一个新密钥.同样,新密钥应与COM对象的GUID相同.不需要在此键下添加任何值.
Thanks all who replied. Based on the answers, I thought if I looked long enough I''d find something that would allow me to connect easily.

I found it.

It involves the registry.


1. Locate your COM object GUID under the HKey_Classes_Root/Wow6432Node/CLSID

2. Once located add a new REG_SZ (string) Value. Name should be AppID and data should be the same COM object GUID you have just searched for

3. Add a new key under HKey_Classes_Root/Wow6432Node/AppID .The new key should be called the same as the com object GUID

4. Under the new key you just added, add a new REG_SZ (string) Value, and call it DllSurrogate. Leave the value empty

5. Create a new Key under HKey_Local_Machine/SoftwareClasses/AppID if it doesn''t already exist. Again the new key should be called the same as the COM object''s GUID. No values are necessary to be added under this key.


André的答案是正确的.事实是更基本的:您无法以任何方式以一种方式链接针对不同指令集体系结构的DLL,即使在运行时动态加载程序集并使用Reflection也不行.此外,代码可能会编译,但在运行时会崩溃.因此,只有一种解决方法:针对与机器架构兼容的不同指令集架构的代码只能在不同的进程中运行.结论很明显:唯一的协作方式是使用进程间通信(IPC).如果有人声称某些技术使用诸如COM之类的不同体系结构,则意味着IPC是在后台使用的.

—SA
The answer by André is correct. The fact is more basic: you cannot link DLLs targeted to different instruction-set achitectures in one process in any way, even dynamically loading an assembly during run-time and using Reflection. Moreover, the code may compile but crash during runtime. So, there is only one work-around: codes targeted to different instruction-set architectures compatible with machine architectures can only be run in different process. The conclusion is apparent here: the only way to collaborate is using Inter-Process Communications (IPC). If someone claims that some technology uses different architectures, such as COM, it means IPC is used under the hood.

—SA


这篇关于如何在64位应用程序中使用32位dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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