1

Premise: I have two DLL's, one is 32 bits and 64 bits, they both have the same methods.

Problem: I can't use the 32 bits version everywhere.

[DllImport("Epsonx86.dll")]
private static extern int PrintLine(string line);
[DllImport("Epsonx64.dll")]
private static extern int PrintLine(string line);
...

Apparently, I can't use this:

string dllName = Environment.Is64BitOperatingSystem ? "Epsonx64.dll" : "Epsonx86.dll";

[DllImport(dllName)] //Error here.
...

So, How to make the code work with both without having to make lots of if's?

Edit

I'm heading over Interface implementation... Well, I got to work with an Interface.

 IEpson print;

 if (Environment.Is64BitOperatingSystem)
 {
     print = new InterfaceEpsonNfx64();
 }
 else
 {
     print = new InterfaceEpsonNfx86();
 }

 print.PrintLine("BlaBla");
Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79
  • What you need to do is give both DLLs the same name and put them in a different directory. Or give them both the same name and only install one of them, to match the bitness of the executable. – David Heffernan Nov 06 '14 at 12:50

0 Answers0