About. NET-compiled target platform (anycpu,x86,x64)

Source: Internet
Author: User

Today there are project code to receive customer feedback, requiring All EXE project target platform to be designated as x86 , and all DLL project target platforms are all designated as AnyCPU .

Let's take a look at what this target platform does, and what's the difference between the options. In VisualStudio, the following options are available in the compilation settings: x86: Compiles the assembly to run by the 32-bit common language runtime that is compatible with x86. x64: Compiles the assembly to run by the 64-bit common language runtime on the computer that supports the AMD64 or EM64T instruction set. ANYCPU: (The default value) compiles the assembly to run on any platform.Itanium: Compiles the assembly to run by the 64-bit common language runtime on the Itanium processor-based computer. The behavior is as follows: on 64-bit Windows operating systems: Assemblies compiled with x86 will be executed on the 32-bit CLR running under WOW64.with x64Compiled Assemblieswill be in executed on the 64-bit CLR. Executable files compiled with ANYCPU will be executed on the 64-bit CLR. A DLL compiled with ANYCPU will execute on the same CLR as the process that loaded it. On a 32-bit Windows operating system: with x86 oranycpuCompilethe assembly will beexecuted on the bit CLR. with x64The compiled assembly cannot be run.  after figuring out these differences, it makes no sense to look back at what the customer is asking for. the first thing to know is that the client wants the program to run in every system above WinXP (either 32-bit or 64-bit). Therefore, it is impossible to choose x64,Itanium is not going to choose this for a special processor.  do you have any problems choosing the default mode of any CPU? First look at any CPU and x86 executable (EXE) in 32-bit and 64-bit under what difference, any CPU under 32 bits, EXE will be 32 bit execution, and under 64 bit, EXE will be executed in 64 bit. And x86 's words are always executed with 32 bits. Customers want to use the x86, that is, do not want 64-bit under the 64-bit way to execute EXE program. My analysis is due to the possible existence of a third-party 32-bit DLL in the system, once the 64-bit EXE is used, it will not be called when calling to a 32-bit DLL. While the DLL, the customer wants to take any CPU,I analyzed theThe reason is that the actual operation of the DLL is affected by the exe that called it, so set it to any CPU. And if it's set to x86, it doesn't seem to be a problem, but it can't run in the 64-bit CLR, not too good. Reference: Http://msdn.microsoft.com/zh-cn/library/zekwfyz4 (vs.80). aspx------------------------------add that you can use the. NET The CorFlags command provided in the SDK looks at the target platform of the assembly and can modify it so that it does not have to be recompiled. But why can't a 64-bit EXE call a 32-bit DLL?

"References" http://blog.sina.com.cn/s/blog_7dd67c4b010128ya.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.