IL code is platform agnostic. So as long as there’s a JIT compiler for your processor everything should work just fine. That’s why by default the compilation mode for a regular .NET project states “Any CPU”.
The image you get when compiling the application or a class library will always contain IL*, but you can force the platform compatibility with a special flag (that can even be turned on and off post-compile). Why would you ever do this?
Because if you’re using a mixed assembly which is partly IL and partly unmanaged native code (usually C++) then you are already tied to a platform.
This problem shows up mostly when you try to use native (or mixed) 32–bit class library from a pure .NET application.
Fortunately, the solution is easy – you don’t need to mark all of your assemblies as 32–bit (x86), just the main executable. Once that starts in x86 mode, all the other DLLs will load as x86 too.
Why worry about this? Because more and more people will be using 64–bit OS-es now that memory is dirt cheap (you can never have too much memory). Out of three computers I use on a daily basis, two are 64–bit (XP and Vista) and only one is 32–bit (XP). There is a good chance I’ll soon be replacing the remaining 32–bit laptop with a new one with a 64–bit Vista.
*Unless you ngen the image, that is.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5