【发布时间】:2014-03-05 13:24:02
【问题描述】:
在我的登台服务器中,我安装了 .net 4.5 版,并开发了我的 asp.net mvc Web 应用程序。
现在,当我在生产环境中部署应用程序时,它在 web.config 文件中引发了错误:-
parser Error Message: The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, '<compilation targetFramework="4.0">'). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework.
Source Error:
Line 63: </caching>
Line 64: <customErrors mode="RemoteOnly" />
Line 65: <compilation targetFramework="4.5">
Line 66: <assemblies>
Line 67: <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Source File: C:\inetpub\wwwroot\web.config (file:///C:/inetpub/wwwroot/web.config) Line: 65
_____
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 So
我检查了生产中的 .net 版本,它是 4.0 而不是 4.5。
所以现在我将在生产服务器上执行以下操作:-
- 我将在生产环境中下载并安装 .net 4.5 版。
- 一夜之间重新启动生产服务器。
那么这会解决问题吗,还是我必须在 IIS 上重新部署整个 asp.net mvc 以使其采用新的 .net 版本?
【问题讨论】:
-
可以,前提是您在部署应用程序时将应用程序池设置为使用 4.5 而不是 4.0
-
所以我不想修改我的代码,所以我将在生产环境中安装 .nt 版本 4.5 以保持我的代码不变......
-
那么在生产上安装 4.5 后它会工作吗?无需重新部署东西?
-
是的,您可以安装 .NET Framework 4.5,您将重新启动计算机,但无需重新部署。您的代码已投入生产,您报告的问题并非基于您的代码。完成重新启动后,转到您的站点应用程序池并确保将目标框架更改为 4.5,这应该可以解决您的问题。
-
但我认为我不需要更改应用程序池以使用 4.5 ...
标签: .net asp.net-mvc asp.net-mvc-4 iis