[英]If C# code is JIT compiled why do I have to choose a target platform in Visual Studio when building?
My assumption could be wrong, but I thought that the main advantage of JIT compilation is that allows a single distributable that the JIT compiler will compile for the target machines particular hardware. 我的假设可能是错的,但我认为JIT编译的主要优点是允许JIT编译器为目标机器特定硬件编译的单个可分发。
If this is true, then why can a target platform be specified when compiling C#? 如果这是真的,那么为什么在编译C#时可以指定目标平台?
Thanks. 谢谢。
Much of the time you don't need to, and the default is okay. 很多时候你不需要,默认是可以的。 However, there are some circumstances where the default
Any CPU
can cause problems. 但是,在某些情况下,默认的
Any CPU
都可能导致问题。 One example is if you have a dependency on a 32-bit unmanaged dll. 例如,如果您依赖于32位非托管dll。 If you leave it at
Any CPU
and try to run this on a 64-bit system, the JITter will build your .Net code into a 64-bit executable, which will then fail to successfully load the 32-bit dependency. 如果将它保留在
Any CPU
并尝试在64位系统上运行它,JITter会将.Net代码构建为64位可执行文件,然后无法成功加载32位依赖项。 There are other cases as well where it's advantageous to be able to specify the platform. 还有其他情况,能够指定平台是有利的。 Another example is when you're building an application that you know will be used to load very large data sets into memory.
另一个例子是当你构建一个你知道将用于将非常大的数据集加载到内存中的应用程序时。 If those data sets could exceed the virtual address space available for 32-bit programs, you may need to specify that you're building a 64-bit application.
如果这些数据集可能超过32位程序可用的虚拟地址空间,则可能需要指定您正在构建64位应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.