Question

I am looking for advice for the best way to set up a new VS2012 C# project. I want to target both x86 and x64 architectures. However, I have 3rd Party DLLs that I must reference. There are two versions of the same DLL provided; one compiled for x86 and x64. That being said, do I need to target x86 and x64 specifically? I wouldn't think that AnyCPU or the new AnyCPU32bitpreferred would work for my situation. Also, what's the correct way to reference the DLLs in the same project (they have the same name but one is 32-bit and the other is 64-bit). Thank you.

No correct solution

OTHER TIPS

Your Project setup should be focussed on the "target" computer, not on compilation computer. If your target system will be 32bits, then you should reference the x86 version of the 3rd party libraries, in other way if your target computer will be 64bits then you should reference the x64 version. You shouldn't/couldn't reference to both libraries into the same Project. In any case you could mantain two parallel versions of your Project which differs just in references section. If you need to create x64 installers then you probably also would check the answer of this question: BadImageFormatException x64 Issue

AnyCPU could be useful when you don't redistribute the 3rd party DLLs, and you asume they were previouly installed on target system, and your development don't need/use any special feature of x64 set. In this case, your code will invoque the 3rd party DLL in the format they were installed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top