0

I have a run time dependency on a 32bit dll which will be consumed in my 64bit exe for certain functionality. As this 32bit dll is third party dll and they aren't willing to provide us with 64bit dll, what would be the best approach solve this issue.? Currently i have thought of implementing new 32 bit exe to handle this dependency that communicates between 32 bit dll and 64 bit exe.

One of the approach that I have tried is creating a new 32 bit exe. So the 64 bit process communicates with the 32 bit exe which in turn consumes the 32 bit dll (3rd party).

Any suggestion on this would be really useful.

Abishek Alva
  • 89
  • 1
  • 7
  • 1
    Can you not just compile your program as 32 bit? Is there a specific reason you're compiling as 64? – Dispersia Feb 24 '16 at 16:18
  • To my knowledge you don't have a problem using a 32bit in a 64. it's the other way around that it's not possible. What error do you encounter? – Miguel de Sousa Feb 24 '16 at 16:19
  • @MigueldeSousa I'm not sure how you'd load a 32 bit DLL and guarantee that every pointer it gets passed is in the lowest 4GB that it could address. I'm not saying it's impossible, I've just never seen it done :) – Joachim Isaksson Feb 24 '16 at 16:21
  • 1
    @MigueldeSousa a 64bit executable cannot load a 32bit (executable) dll – Alex K. Feb 24 '16 at 16:21
  • Ok my bad :) google it and found this https://social.msdn.microsoft.com/Forums/vstudio/en-US/644c2f9c-f06a-496a-b497-6420a7919fdb/64-bit-app-calling-32-bit-dll?forum=csharpgeneral – Miguel de Sousa Feb 24 '16 at 16:27
  • I think @Alex K is correct, but might try this and you'd have to look at the dependencies of the 32bit dll and make sure it is not loading any other 32bit dlls. If not you could try flipping the [CorFlag](https://msdn.microsoft.com/en-us/library/ms164699(v=vs.80).aspx) to make it run as anycpu - unlikely it will work but I've seen it go both ways. – Chad Dienhart Feb 24 '16 at 16:29
  • @Dispersia 64bit executable cannot load 32 bit dll that's were my problem lies and my application has to be migrated to 64 bit – Abishek Alva Feb 24 '16 at 16:30
  • @AbishekAlva ok, but why does it HAVE to be migrated to 64 bit? – Dispersia Feb 24 '16 at 17:12
  • All the applications undergo this change. This is the decision that has come from higher level. We had also communicated to the third party for availability of 64 bit dll but they are unlikely to provide it. – Abishek Alva Feb 24 '16 at 17:34

1 Answers1

0

You could make the 32 bit EXE a service using Windows Communications Foundation and a Named Pipe binding. The service would reference the 32 bit Dll. Then your 64 bit process can communicate with the service. It will be tedious to define all the data contracts so you can extract what you need out of the dll. Still, it beats setting up a roll-your-own interprocess communication mechanism.

Are you sure devising a work around for using the dll is not more difficult than implementing the functionality needed from the dll yourself?

Chris S.
  • 161
  • 1
  • 7