.NET Framework 4.0-无法运行 2.0 的 ASP.NET 程序解决

作者:vkvi 来源:ITPOW(原创) 日期:2009-12-4

服务器安装了 .NET Framework 4.0 ,运行 2.0 的 ASP.NET 程序时报错:

The application domain or application pool is currently running version 4.0 or later of the .NET Framework. This can occur if IIS settings have been set to 4.0 or later for this Web application, or if you are using version 4.0 or later of the ASP.NET Web Development Server. The <compilation> element in the Web.config file for this Web application does not contain the required 'targetFrameworkMoniker' attribute for this version of the .NET Framework (for example, '<compilation targetFrameworkMoniker=".NETFramework,Version=v4.0">'). Update the Web.config file with this attribute, or configure the Web application to use a different version of the .NET Framework.

在 4.0 版本中,compilation 必须包含 targetFrameworkMoniker 属性,所以我们应该重新配置下 web.config:

<?xml version="1.0" encoding="utf-8"?>
    <compilation targetFrameworkMoniker=".NETFramework,Version=v4.0" />

是不是说您的 ASP.NET 程序已经变成 4.0 的呢?不是的,只是用以说明这个 2.0 的 ASP.NET 程序在 4.0 中运行。