.net - 我的代码将在哪个 CLR 中执行?

标签 .net clr

考虑到我的开发机器中有两个版本的 .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/

相关文章:

c++-cli - C++/CLI 哪个类包含全局函数?

c# - WPF .exe - 大文件大小

c# - 删除数据网格中的行选择器

c# - 在 SolrNet 中记录 debugQuery 响应的简洁方法

c# - 如何在托管代码中获取 EIP 的当前值?

c# - 调用接口(interface)成员的虚方法的CLR实现

C# 'is' 运算符性能

c# - 我在哪里可以找到 .net 源代码中的 ValueType 构造函数?

.net - 如何在 HttpWebRequest 中使用 cookie

asp.net - 是创建一个标签并从代码隐藏更新其文本更好,还是创建多个标签并根据需要显示/隐藏标签更好?