C# projects using both X86 and Any CPU

前端 未结 2 1952
日久生厌
日久生厌 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:28

    If any of your code calls 32-bit x86 libraries, the entire process needs to load as x86. No exceptions.

    To do this, set the EXE project to x86, set DLL projects that have native x86 dependencies to x86, and for pure managed DLL projects you can use AnyCPU -- .NET will load them as x86 for your x86 EXE, but they can also load into x64 EXEs.

    Remember that x86 code runs just fine on x64 processors running x64 Windows, with the help of the WOW64 compatibility layer.

    (with limited exceptions: on Windows Server edition, WOW64 is an optional component, and in the preinstall environment there is no WOW64).

提交回复
热议问题