Archived Forum Post

Index of archived forum posts

Question:

Is there a way to target Any CPU? Or would I need to build two windows clients 32bit & 64bit?

Mar 22 '16 at 20:59

For the Chilkat .NET assembly, is there a way to target Any CPU? Or would I need to build two windows clients 32bit & 64bit?


Answer

You can target AnyCPU, but you'll get a warning message when building the app. All it means is that you must provide the matching memory-model DLL at runtime (i.e. 32-bit on a 32-bit system and 64-bit on a 64-bit system).

If the "Prefer 32-bit" checkbox is checked in your project settings, then your app will always run 32-bit, even on 64-bit systems. In my opinion, this is the best and least troublesome option. If your app isn't using more than 4GB of memory and is not computationally intensive such that it really benefits from 64-bit, then there's no real gain from a 64-bit address space w/ potential 64-bit CPU instructions.

Or.. if you'll never encounter a 32-bit Windows computer (which are getting harder to come by these days), then just produce a 64-bit build and forget about 32-bit. (But even still, 32-bit may be a better choice.)

Finally, there are ways of dynamically loading the assembly at runtime based on what is required. Therefore, an AnyCPU managed app can ship with both 32-bit and 64-bit Chilkat assemblies and then load the required one at runtime.

See http://cknotes.com/dynamically-loading-a-32-bit-or-64-bit-net-assembly-at-runtime/