考虑到我的开发机器中有两个版本的 .Net(.Net 1.1,2.0)。如果我要针对 .Net 1.1 部署我的应用程序 X 并再次部署另一个应用程序 Y 的 .Net 2.0 框架。
现在我需要知道我的两个应用程序将在哪个 CLR(1.1 或 2.0)中运行?
还要说明原因吗?
最佳答案
此 MSDN article相当清楚地解释了这一切:
The version of the .NET Framework that an application runs on is determined as follows:
If the version of the .NET Framework that the application was built against is present on the computer, the application runs on that version.
If the version of the .NET Framework that the application was built against is not present and a configuration file does not specify a version in a
<supportedRuntime>
Element, the application runs on the latest version of the .NET Framework that is present on the computer.If the version of the .NET Framework that the application was built against is not present and the configuration file specifies a version in a
<supportedRuntime>
Element, the application runs on the latest version that is specified in the application configuration file and is present on the computer.
正如 Sam 在评论中提到的,一个异常(exception)是 ASP.NET,其中使用的版本是在 IIS 管理控制台中指定的。
关于.net - 我的代码将在哪个 CLR 中执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1259909/