C# projects using both X86 and Any CPU

前端 未结 2 2048
日久生厌
日久生厌 2021-02-08 17:37

Say I have 2 Winform projects A, B.

Project A (target .NET 2.0) has to be run on x86 (it is an external library) and for legacy reasons project B (target .NET 4.0) has

2条回答
  •  春和景丽
    2021-02-08 18:19

    You may find the answer to your question in following blog post

    http://blogs.microsoft.co.il/sasha/2012/04/04/what-anycpu-really-means-as-of-net-45-and-visual-studio-11/

    Here is summary

    .net 4.0

    What AnyCPU used to mean up to .NET 4.0 (and Visual Studio 2010) is the following:

    •If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.

    •If the process runs on a 64-bit Windows system, it runs as a 64-bit process. IL is compiled to x64 machine code.

    •If the process runs on an Itanium Windows system (has anyone got one? ;-) ), it runs as a 64-bit process. IL is compiled to Itanium machine code.

    .net 4.5

    In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, “Any CPU 32-bit preferred”, which is the new default (overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu32bitpreferred). When using that flavor of AnyCPU, the semantics are the following:

    •If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.

    •If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.

    •If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.

提交回复
热议问题