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

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

问题描述

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

我已经注意到,编译C#code在VS的时候,有典型的编译选项的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才可以编译成中间字节code,而第一个选项编译成机器code(这听起来不太可能我)?还是其他什么东西?

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?

推荐答案

  • 任何CPU :运行作为一个32位的过程中,可以加载任何CPU 86 组件,将获得 BadImageFormatException 如果它试图加载的 64 组件。

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.

    86 :相同的任何CPU

    64 BadImageFormatException 总是

    • 任何CPU :运行作为一个64位的过程中,可以加载任何CPU 64 组件,将获得 BadImageFormatException 如果它试图加载的 86 组件。

    • 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.

    86 :运行作为一个32位的过程中,可以加载任何CPU 86 组件,将获得 BadImageFormatException 如果它试图加载的 64 组件。

    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.

    64 :相同的任何CPU

    这是 JIT编译器生成的程序集code这是与基于该标志所要求的目标相兼容。

    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天全站免登陆