C# 为 32/64 位编译还是为任何 cpu 编译? [英] C# compiling for 32/64 bit, or for any cpu?

查看:28
本文介绍了C# 为 32/64 位编译还是为任何 cpu 编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
Visual Studio任何 CPU"目标

我注意到在 VS 中编译 C# 代码时,通常有针对 32/64 位系统编译的选项,也有针对任何 cpu 编译的选项.

I've noticed that when compiling C# code in VS, there's typically options for compiling for 32/64 bit systems, and there's also one for compiling for any cpu.

这两个选项有什么区别?选择任何 CPU 是否仅编译为中间字节码,而第一个选项编译为机器码(这听起来不太可能)?或者别的什么?

What's the difference between the two options? Does choosing any CPU only compile down to an intermediate byte code while the first option compiles down to machine code (this sounds unlikely to me)? Or something else?

推荐答案

32 位 机器上:

  • Any CPU:作为 32 位进程运行,可以加载 Any CPUx86 程序集,将获得 BadImageFormatException 如果它尝试加载 x64 程序集.

    On a 32-bit machine:

    • Any CPU: runs as a 32-bit process, can load Any CPU and x86 assemblies, will get BadImageFormatException if it tries to load an x64 assembly.

      x86:与任何 CPU 相同.

      x64:BadImageFormatException 总是.

      • Any CPU:作为 64 位进程运行,可以加载 Any CPUx64 程序集,将获得 BadImageFormatException 如果它尝试加载 x86 程序集.

      • Any CPU: runs as a 64-bit process, can load Any CPU and x64 assemblies, will get BadImageFormatException if it tries to load an x86 assembly.

      x86:作为 32 位进程运行,可以加载任何 CPUx86 程序集,将获得 BadImageFormatException 如果它尝试加载 x64 程序集.

      x86: runs as a 32-bit process, can load Any CPU and x86 assemblies, will get BadImageFormatException if it tries to load an x64 assembly.

      x64:与任何 CPU 相同.

      JIT 编译器根据该标志生成与请求目标兼容的汇编代码.

      It is the JIT compiler that generates an assembly code that's compatible with the requested target based on this flag.

      这篇关于C# 为 32/64 位编译还是为任何 cpu 编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆