0

I have a 64bit application that need to call a legacy c++ dll for some analysis. Usually that dll is a DSS logic that takes in a file, process it, and writes out the output to file.

I tried to use the function using DllImport but, it doesn't work from my application. After that I created a class library(target x86) that contains all the function to interact with regular dll but still it fails. But when I use the class library from a 32bit console application everything works like it should.

After some research and other articles on Stack Overflow, I might need to use COM. I exposed the COM interfaces and registered the dll using Regasm but how do I refer the COM dll into my 64bit application. When I try to refer the same it gives following error.

Error while adding reference to tlb or COM dll

What should I do to get this working

Mohit Vashistha
  • 1,824
  • 3
  • 22
  • 49
  • This doesn't solve your problem, you really do need a 64-bit version of that C++ DLL to load it into a 64-bit process. If that's impossible then you'll need to use a 32-bit process. Write a little helper EXE that your main program starts. Use one of the .NET interop mechanisms to talk to it, like WCF, sockets or named pipes. – Hans Passant Jul 26 '13 at 10:28
  • I can't have 64-bit version of it.I have separated the code that talk to dll in another x86 dll that been refereed by C#, shouldn't it be loading a x86 dll into x86 space? – Mohit Vashistha Jul 26 '13 at 10:34
  • There are no such "spaces" in a 64-bit process. – Hans Passant Jul 26 '13 at 10:39
  • Is there any way to achieve this?? – Mohit Vashistha Jul 26 '13 at 10:48
  • I've tried the same thing a while ago, from what i understand you can't load a x86 dll in x64 app, so you can either recompile one of then into another form or write a wrapper around the legacy dll and use Process.Start – Bobby Tables Jul 30 '13 at 12:31

0 Answers0