【问题标题】:ASP.NET Web App using the wrong (2.0) CLR version (instead of 4.0)ASP.NET Web App 使用错误的 (2.0) CLR 版本(而不是 4.0)
【发布时间】:2011-02-13 14:25:53
【问题描述】:

我刚刚将我一直在开发的一个 asp.net Web 应用程序部署到一台新的开发机器上。这是一个从 3.5 转换而来的 4.0 项目。出于某种原因,当我尝试通过默认网站下的 IIS 网站访问该网站时出现以下错误:

无法识别的属性“targetFramework”。请注意,属性名称区分大小写。

它在 ASP.NET 错误页面上将此列为配置错误:

 <compilation debug="true" targetFramework="4.0"/>

但是,我注意到在错误页面的底部,版本信息表明它使用的是版本 2 而不是版本 4。有人知道如何解决这个问题吗?

我已确保我的默认网站使用 .net 4 / 集成应用程序池,并且在进行此更改后我循环了 iis。还是不走运。这是我的整个 web.config 文件:

    <?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings>
        <add name="EventMasterConnectionString" connectionString="Data Source=localhost;Initial Catalog=BashBidder;Integrated Security=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>
        <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
        <compilation debug="true" targetFramework="4.0">
        </compilation>
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Windows"/>
        <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
    <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
</configuration>

感谢您的帮助!

【问题讨论】:

    标签: iis web-config asp.net-4.0


    【解决方案1】:

    您必须配置您的应用程序池,以便它使用 4.0 版框架。

    This procedure 解释如何在 IIS 7 上执行此操作,that one 在 IIS 6 上说明。

    【讨论】:

    • 嗯?我相信 OP 希望在 4.0 版中运行他的应用程序。
    • @Victor,很好,以某种方式颠倒了问题。答案已更新,感谢您的提醒:)
    • 谢谢。应用程序池已针对版本 4,而不是版本 2。仍然没有运气。
    • 你是对的。事实证明,我的网络表单标记中有一个错误导致了这种情况。然而,更多的发展。我现在收到 501.19 说配置文件无效(实际错误是无法读取配置文件)。如果我按 f5 并让它从 withing VS 生成服务器地址和端口,我的应用程序运行良好......但如果我尝试通过我的 IIS 虚拟目录,我会收到配置错误。有什么想法吗?
    • 呃。刮那个。现在一切都很好。我忘记了我更改了项目名称并且没有更新我的 VD 的路径。感谢您的宝贵时间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多