Are there any considerations needed to be taken running your .net program on x64 vs x86?

后端 未结 7 1052
Happy的楠姐
Happy的楠姐 2021-01-17 11:05

I believe the architecture type (x86 vs x64) is abstracted away for you when making .Net programs, but are there any other considerations that can cause problems?

相关标签:
7条回答
  • 2021-01-17 11:11

    x64 will allow you to address more memory, but given the same code, it will use more memory than x86.

    0 讨论(0)
  • 2021-01-17 11:14

    Beware of third-party COM libraries or third party .NET libraries that secretly make win32 calls. That's where we had our biggest headaches.

    0 讨论(0)
  • 2021-01-17 11:19
    • Reading and writing to 64 bit values is not thread safe on a 32 bit platform. Reading a 64 bit value takes two operations which could be interrupted by a context switch. See the MSDN article on Threading.Interlocked.Read for more information.

    • Also agree entirely with torial's answers! :-)

    0 讨论(0)
  • 2021-01-17 11:20

    In my experience porting an Asp.NET application was basically flawless. Run on 32 bit machine and on 64 bit and no problem happens, beside having more memory available. This happens because a lot of the issues already mentioned (registry, threading and so on) have been managed by Asp.NET and you need to properly fix them to run in the Asp.NET environment.

    Client side (windows form) the same happened but it if you've used some "unsafe" APIs to get special folders or registry access then some problem can happen, as already pointed.

    Regards Massimo

    0 讨论(0)
  • 2021-01-17 11:28

    From the MSDN doco, among other considerations:

    In many cases, assemblies will run the same on the 32-bit or 64-bit CLR. Some reasons for a program to behave differently when run by the 64-bit CLR include:

    • Structs that contain members that change size depending on the platform, such as any pointer type.

    • Pointer arithmetic that includes constant sizes.

    • Incorrect platform invoke or COM declarations that use Int32 for handles instead of IntPtr.

    • Casting IntPtr to Int32

    Also, default file locations.

    0 讨论(0)
  • 2021-01-17 11:36

    This article has a lot of good issues to be aware of: http://osnews.com/story/20330/Windows_x64_Watch_List

    Personally, my boss has a 64-bit Vista computer, and I program in a 32-bit mode. We've run into the following issues:

    • Registry for 32 bit apps gets hidden (sort of) into a Wow6432Node folder. Not all apps you are used to finding a path for in the registry will be in that node (SQL Server won't, for instance).

    • SysWow64 in the C:\Windows folder can cause issues of DLLs not being where they are needed (we had this issue w/ a 3rd party licensing component).

    • Sometimes the files you need are in "C:\Program Files (x86)", rather than "C:\Program Files". Sucks too.

    0 讨论(0)
提交回复
热议问题