简体   繁体   English

如果C#代码是JIT编译的,为什么我在构建时必须在Visual Studio中选择目标平台?

[英]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.

相关问题 在Visual Studio命令提示符2010中构建c#dll时如何指定.net目标框架? - How to specify .net target framework when building c# dll in Visual Studio Command Prompt 2010? 为什么当我使用 !!= C# 时代码会被编译 - Why does the code get compiled when I use !!= C# Visual Studio 2012 Express C#为什么没有“使用组织”菜单选项? - Visual Studio 2012 Express C# Why do I have no “Organize Using” menu option? C# Visual Studio - 为什么会出现错误“并非所有代码路径都返回值”? - C# Visual Studio - why do I get an error “Not all code paths return a value”? 为什么当我想通过 C# 运行 GAMS 代码时,visual studio 给我错误? - Why does visual studio gives me error when I want to run the GAMS code via C#? Visual Studio C# 目标平台 x86 但 nuget package 在我看来是 x64 - 程序运行时出错 - Visual Studio C# target platform x86 but nuget package seems to me x64 - error when program runs Visual Studio平台目标 - Visual Studio Platform target C# Visual Studio Code:构建 Hello World 可执行文件 - C# Visual Studio Code: Building a Hello World executable 我可以为C#创建自己的JIT \\ Interpreter \\ Compiler并在Visual Studio中使用它吗? - Can I make my own JIT\Interpreter\Compiler for C# and use it in Visual Studio? 使用msbuild构建时出现C#版本错误,使用Visual Studio可以 - C# version error when building with msbuild, ok with Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM