【问题标题】:httpRuntime targetFramework and dlls that depend on higher version of the .net frameworkhttpRuntime targetFramework 和依赖于更高版本的 .net 框架的 dll
【发布时间】:2018-05-07 17:27:58
【问题描述】:

我的 asp.net mvc 5 应用程序的 web.config 文件具有 httpRuntime targetFramework="4.5"compile targetFramework="4.5.1"。我最近开始使用 dapper,这需要我将应用程序重新定位到 4.5.1。重新定位应用并没有改变httpRuntime targetFramework

我是否需要在 web.config 文件中也将 httpRuntime targetFramework 设置为 4.5.1 还是应该保持原样?测试和生产系统运行 .Net 框架4.5.2

谢谢

更新:我发现了一篇有趣的文章:https://dennisgorelik.livejournal.com/132999.html。还有这个:https://blogs.msdn.microsoft.com/webdev/2012/11/19/all-about-httpruntime-targetframework/

【问题讨论】:

  • 如果测试和生产系统运行.Net framework 4.5.2,你也应该使用它进行本地开发。
  • 我实际上运行的是 4.5.2 并且我没有看到任何问题。 httpRutime targetFramework 上的文档不是很有帮助。
  • docs 没有描述如果缺少httpRuntime targetFramework 会发生什么:
  • 根据第二个链接:If the targetFramework attribute is not present, we assume a default value of "4.0"

标签: c# asp.net asp.net-mvc


【解决方案1】:

实际上并没有比 4.5 更新的框架。有较新版本的功能升级,但它们都安装到同一个目标文件夹(.NET 4.5 之一)并覆盖现有文件。 这也适用于 4.6.x 或 4.7.x。这不同于以前的框架版本,它们可以(或必须)共存。

事实上,您可以使用此 hack 在具有较旧框架的 Web 服务器上运行具有较新框架 (>= 4.5) 的应用程序。当然,前提是你没有使用较新框架的框架类。否则你会得到一个丑陋的类加载器异常。 (BTDT)

为避免此类陷阱,我建议不要在 web.config 文件中使用不一致的版本,除非您有充分的理由这样做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-27
    • 2017-05-06
    • 1970-01-01
    • 2010-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-30
    相关资源
    最近更新 更多