Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

c# - 32 bit dll importing in 64 bit .Net application

I'm having a problem, I've been trying to solve it since yesterday but no luck. I have a 32-bit Delphi DLL which I want to import it in to a .NET WIN Application. This application has to be built on ANY CPU mode. Of course, the exception BadImageFormatException is thrown, which means that 64-bit applications can't load x86 DLLs. I googled around and found a solution, it said that I have to do wrapper, but it wasn't clear for me. Can anyone tell me how to solve this problem, is there any possible way that I can import a 32-bit Delphi DLL in to a program built under any CPU architecture (64-bit, 32-bit) or maybe another solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What you have to do is write a wrapper application that hosts the 32-bit DLL file, in a 32-bit process.

Your 64-bit application then has to talk to this 32-bit process, through network means, or by making the DLL functions available through a COM object, or similar.

You can not run a 32-bit DLL inside a 64-bit process, no matter how hard you try, so you need to run it in a 32-bit process.

If compiling your application for 32-bit only is not an option, you have no choice but to create a host application.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...