I was lucky enough to have a spanking new 64-bit dev box bestowed upon me and have been loving the response I’m getting out of the extra ram. Compilation times have been massively reduced and switching from design to code view when developing UIs no longer takes an age.
However, all was not sweetness and light. I found I was no longer able to edit code live when debugging. Instead I was receiving this message: “Changes to 64-bit applications are not allowed.”
What?! So all my productivity gains have been eliminated by having to rebuild when making tiny edits? I don’t usually condone coding on the fly while debugging, but when catching UI events, especially from certain third party grid controls, I find it very useful.
I think the problem is due to something being not quite fully implemented in the 64-bit edition of VS, but the workaround is simple enough. Just change the CPU you’re targeting to x86 while you’re developing.
The target platform is oft misunderstood. Changing this value does not optimise your deployment for that platform, it merely inserts a header into your assembly that tells the CLR how to run it. The platform target declares the developer’s intention for which OS bitness the application was intended for. Targeting any cpu will ensure your application runs as a 32-bit app on a 32-bit OS and as a 64-bit app on a 64-bit OS – the CLR will work out what to do. If you have any third party components that are reliant on running under a 32-bit process, then choose x86 and the app will run as a 32-bit on a 64-bit OS. If your application was developed specifically for a 64-bit OS, target x64 which will ensure the application can’t run on a 32-bit OS. Changing the target cpu will not change the IL that your program compiles to, nor will it optimise your application for 64-bit.
Another 64-bit misconception is that a .net int will compile to an int32 in a 32-bit OS and to a int64 in a 64-bit OS. This is not true. int is shorthand for int32 regardless of OS bitness as defined in the c# language spec. If you want an int64 just declare a long.