在64位.NET应用32位的dll进口NET、dll

2023-09-04 00:25:14 作者:爷、无限嚣张

您好 我有一个问题,我试着去解决它,因为昨天,但没有运气。 我有32位的Delphi DLL,我想在.NET Windows应用程序导入。这个应用程序都必须建立在任何CPU模式。当然,还有BadImageFormatException到来,这意味着在64位应用程序不能加载DLL的x86 .. 我用Google搜索周围,找到解决方案,它说我必须做的包装,但目前还不清楚我。任何人可以告诉如何解决这个问题,就是在那里,我可以输入32位的Delphi中的DLL程序builted任何可能的方式任何CPU或x64模式(也许其他解决方案)。

hello 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可见。这使得调用你的包装DLL通过其COM接口。

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服务器。 看一看这太问题关于这个主题的一些更多的信息:访问86 COM从64位.NET 。

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.