tags:

views:

179

answers:

2

While working on a .Net application (let's say an Asp.Net one), are there any differences in the way you would do things while working on the 64 bit platform, as compared to working on a 32 bit platform.

I would imagine very little since you are working on the framework, and the framework is taking care of most things for you, right?

But, please give your comments.

Thanks.

+2  A: 

There are two cases where considering 64-bit-ness might be interesting:

  1. you need to consider containers that have more than 2^31 elements. The standard array .Length property returns Int32, and is thus not capable of representing large arrays - which you can't create in a 32-bit VM anyway. In a 64-bit VM, you should use LongLength instead (unless you know that you have less than 2^31 elements). Unfortunately, many standard collection classes don't seem to support large numbers of elements at all.
  2. you can use the long type with fewer concerns about performance: in the 64-bit version, a long fits into a register, whereas in the 32-bit version, the JIT code will need multiple machine instructions for a single long operation.
Martin v. Löwis
+3  A: 

If you're using p/invoke then you need to be sure that you've got 64bit versions of the DLLs available. This isn't an issue if you're calling MS supplied DLLs such as kernel32 as they've got the same name on the 32 and 64 bit platforms (bizarre, I know) and so your 64 bit app will implicitly link to the correct version. However, if you're using 3rd party DLLs and your 64bit app tries to link to a 32bit DLL you'll get a runtime exception.

This also means that if you're using in-process COM object you'll have a problem. A 64bit app can call an out-of-process COM object that's 32 bit (and vice-versa) as you're moving across a process boundary and COM will take care of the marshalling for you.

Other than this, the framework takes care of most things for you. You never really have to worry about pointer sizes and the clr types have explicit sizes (int is always 32 bits, long always 64 bits). In a pure .NET world there's very little to worry about. It's when you start moving outside the sandbox that you have to be more careful.

Sean