locked
Any CPU vs x86 vs x64 Solution Platforms RRS feed

  • Question

  • Hi,

    I have my projects in VS 2008 SP1 and is using .NET 3.5 SP1. Till now we are developing application in Any CPU platform setting for all the projects and supported only 32-bit platforms. Now we are going to support 64-bit OS platforms as well.

    Q-1. What difference it makes by building solution for Any CPU, x86 and x64 platform?

    Q-2. Will it make any difference if I build my application using Any CPU platform setting and run on x64 platform?

    Q-3. What are the advantages of creating different builds for x86 and x64? Any performance gain? anything considerable change?

    Q-4. I have my VC++ dll library which is imported in one of my C# project as well. What changes are required in that VC++ dll to make it running on both x86 and x64?

    Appreciate your inputs.

     


    Regards, Jigs
    Thursday, September 30, 2010 5:59 AM

Answers

  • Hi,

    Thanks for your post.

    For Q1-Q3:

    AnyCPU will compile your assembly to run on any platform. DLLs and EXEs compiled with AnyCPU option will behave with sutle difference. On a 64-bit Windows operating system, EXEs compiled with this option will execute on the 64 bit CLR, while DLLs compiled with this option will execute on the same CLR as the process into which it is being loaded. So, if a 32bit EXE load a DLL that is compiled with this option, the process is 32bit so the DLL will run on the 32bit CLR.

    x86 option compiles your assembly to be run by the 32-bit, x86-compatible common language runtime. On 32bit platform, the EXEs will run as 32bit process. On 64bit platform, the EXEs will run under WOW64 mode.

    x64 option compiles your assembly to be run by the 64-bit common language runtime on a computer that supports the AMD64 or EM64T instruction set.

    Also please take a look at: How to: Optimize an Application for a Specific CPU Type

    For Q4:

    Please take a look at : How do exes/dlls generated with the /platform:x switch interact?

     


    Please mark the right answer at the right time.
    Thanks,
    Sam
    • Proposed as answer by Carl Daniel Monday, October 4, 2010 3:27 AM
    • Marked as answer by SamAgain Tuesday, October 5, 2010 6:29 AM
    Friday, October 1, 2010 8:14 AM