32位dll导入64位.Net应用程序 [英] 32 bit dll importing in 64 bit .Net application

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

问题描述

我有一个问题,我试图从昨天解决,但没有运气。
我有32位delphi dll,我想在.NET Win应用程序中导入。此应用程序必须以任何CPU模式构建。当然还有BadImageFormatException来了,这意味着在x64应用程序中无法加载x86 dll ..
我去搜索并找到解决方案,它说我必须做包装,但对我来说并不清楚。任何人都可以告诉如何解决这个问题,是否有任何可能的方式,我可以导入32位Delphi dll在程序builted任何CPU或x64模式(也许另一个解决方案)。

i'm having a problem, i try to solve it since yesterday but no luck. i have 32 bit delphi dll which i want to import in .NET Win Application. this application has to be built on ANY CPU mode. of course, there's BadImageFormatException coming, which means that in x64 application can't be loaded x86 dll.. i googled around and find solution, it said i have to do wrapper, but it wasn't clear for me. can anybody tell how to solve this problem, is there any possible way i can import 32bit Delphi dll in program builted Any CPU or x64 mode(maybe another solution).

推荐答案

一个一般的想法可能是使用托管的32位包装器DLL来包装(非托管)32位DLL,并使COM可见。这可以通过它的COM接口调用你的包装器DLL。

A general idea could be to wrap your (unmanaged) 32-bit DLL with a managed 32-bit wrapper dll and make it COM visible. This allows calls to your wrapper DLL via its COM interface.

你可以使用COM代理来使你的COM DLL成为一个不在进程的COM服务器。
有关此主题的更多信息,请查看此SO问题:访问x86 .NET x86 COM

You can than use a COM surrogate to make your COM dll appear as an out of process COM server. Take a look at this SO question for some further information on this topic: Access x86 COM from x64 .NET.

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

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