GetHashCode() on a 32-bit vs a 64-bit platform

If you compile your .NET application with the standard “Any CPU” option, it will run as a 32-bit process on a 32-bit OS and as a 64-bit process on a 64-bis process.

When you use GetHashCode() the generated hashes on the 32-bit platform will differ from the hashes on the 64-bit platform…

The solution is either to not use the GetHashCode() the way you do it, or if you can’t change the way your program works you can run it in 32-bit mode by setting the 32-bit flag in the executable’s headers using CorFlags.exe.

Set the 32-bit flag:CorFlags.exe YourApplication.exe /32BIT+

Remove the 32-bit flag:CorFlags.exe YourApplication.exe /32BIT-

More info about CoreFlags.exe on MSDN: http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx

This entry was posted in Programming and tagged , , , . Bookmark the permalink.

One Response to GetHashCode() on a 32-bit vs a 64-bit platform

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>