How to avoid 32/64 bit architecture dilemma in Win

2019-07-24 15:49发布

问题:

Possible Duplicate:
What does the Visual Studio “Any CPU” target mean?

We have a WPF application that must work on plenty of Windows machines from Windows XP x32 to Windows 8 x64. Our app includes NHibernate and SQLite. We do not need any feature of x64. How can modify application to run without any problem on all architectures?

  • Our app is in .Net 4.0

回答1:

Unless you have both the 64bit and 32 bit dll's of your external dependences I would just compile for the lowest common denominator i.e: x86 it will install and run correctly on both 32 bit and 64 bit versions of windows.



回答2:

Compile it for the AnyCpu architecture, this will make it x86/x64 agnostic.

Of course this won't prevent issues if you are looking to access bitness specific things like %PROGRAMFILES%, if you do this you will still need to test for bitness using the Environment.Is64BitOperatingSystem property.