【问题标题】:Unrecognized element 'compilers' with old asp.net app on IIS 10.0IIS 10.0 上的旧 asp.net 应用程序无法识别元素“编译器”
【发布时间】:2018-10-04 20:11:25
【问题描述】:

我希望有人能够帮助我们解决我遇到的 IIS / ASP.NET 问题。我的任务是将 ASP.NET 网站从 Windows 2003 32 位服务器上的 IIS 6 移动到 Windows 2016 64 位服务器上的 IIS 10。 我已经使用 PowerShell 安装了 IIS 和 .NET 3.5 Framework,其中包括 .NET 2.0 和 3.0,具有以下功能

$featureList = @('Web-Server','Web-CertProvider','Web-IP-Security','Web-Windows-Auth','Web-Asp-Net', 'NET-Framework-Features')
Install-WindowsFeature -Name $installFeatures -IncludeManagementTools -Source 'D:\sources\sxs' -Restart

接下来创建我的应用程序池和站点如下

New-WebAppPool -Name 'MyApp_AppPool'
Get-Item -Path 'IIS:\AppPools\MyApp_AppPool' | Set-ItemProperty -Name managedRuntimeVersion -Value 'v2.0'
New-Website -Name MyApp -ApplicationPool MyApp_AppPool -HostHeader myapp.domain.ca -IPAddress * -PhysicalPath 'E:\inetpub\wwwroot\MyApp' -Port 80

该站点似乎加载了登录页面,但是在 IIS 管理器中,如果我转到 .NET 编译,我会收到以下错误消息。 执行此操作时出错。

Details:
Filename: \\?\E:\inetpub\wwwroot\PEIWeb\web.config
Line number: 25
Error: Unrecognized element ‘compilers’

这里是 web.config 文件的专家

    <compilation defaultLanguage="vb" debug="true">
        <compilers>
            <compiler language="vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".VB" compilerOptions="/define:Debug=True /define:Trace=True /imports:Microsoft.VisualBasic,System,System.Collections,System.Configuration,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlControls,System.Web.UI.WebControls" />
        </compilers>
        <assemblies>
            <add assembly="Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        </assemblies>
    </compilation>

我已经测试了将托管管道模式设置为集成和经典的应用程序池,并将启用 32 位应用程序设置为 True,但我仍然遇到相同的错误。

我在线阅读,如果在安装 .NET 3.5 Framework 之前安装了 IIS,可能会出现此类错误,因此我使用重新启动服务器管理器、安装的 .NET 3.5 Framework 并重新启动并安装 IIS 来卸载两者,但我仍然得到同样的错误。

我也尝试从以下两个文件夹运行 aspnet_regiis.exe -i,但我仍然收到同样的错误。

C:\Windows\Microsoft.NET\Framework\v2.0.50727 C:\Windows\Microsoft.NET\Framework64\v2.0.50727

如果有人对如何纠正此问题有任何建议,我将不胜感激。

谢谢

【问题讨论】:

  • IIS 10 上的 IIS 管理器只能操作 ASP.NET 4.x 配置。如果您的应用程序仍以 ASP.NET 3.x 为目标,请手动修改 machine.config 和 web.config 文件。
  • 我的印象是,一旦您安装了 .net framework 3.5 并将应用程序池 .NET CLR 版本设置为 v2.0.50727,这实际上将其配置为运行 asp.net 2.x 和 3 .x 应用程序我错了吗?如果是这样,我需要向 machine.config 或 web.config 应用程序添加什么
  • 这太复杂了。应用程序池设置(IIS 设置的一部分)可以,但 ASP.NET 特定设置不行。所以就像我说的,如果设置转到 machine.config 或 web.config 你最好手动为 ASP.NET 2.x/3.x 进行。
  • 嗨@LexLi,这就是我要澄清的地方。由于我不是开发此站点的人并且没有文档,因此我不知道在 machine.config 或 web.config 中放置什么。我已经发布了 web.config 中给出错误的代码,因此我正在寻找有关如何解决此问题的指导。我知道您正在尝试提供帮助,但只是告诉我设置必须去的位置而不指示这些设置应该是什么不幸并不是很有帮助。如果您可以更具体地说明设置应该是什么,我将不胜感激
  • 为此,您不能依赖 Stack Overflow 提供帮助。通过support.microsoft.com 打开支持案例或寻找开发人员。

标签: asp.net vb.net iis windows-server-2016


【解决方案1】:

所以我做了更多的挖掘工作,终于找到了问题所在。

根据 Microsoft 的说法,compile 元素下的 compilers 元素在 .NET 框架 2.0 中已弃用,但仍受支持。最后我将编译器和编译器元素放在 system.codedom 元素下

https://msdn.microsoft.com/en-ca/library/5tc5kc3e(v=vs.80).aspx https://msdn.microsoft.com/en-ca/library/e4hwk57e(v=vs.80).aspx

所以现在代替这个

<configuration>
    <system.web>
        <compilation defaultLanguage="vb" debug="true">
            <compilers>
                <compiler language="vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".VB" compilerOptions="/define:Debug=True /define:Trace=True /imports:Microsoft.VisualBasic,System,System.Collections,System.Configuration,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlControls,System.Web.UI.WebControls" />
            </compilers>
            <assemblies>
                <add assembly="Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            </assemblies>
        </compilation>
    </system.web>
</configuration>

我有这个

<configuration>
    <system.web>
        <compilation defaultLanguage="vb" debug="true">
            <assemblies>
                <add assembly="Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            </assemblies>   
        </compilation>
    </system.web>
    <system.codedom>
        <compilers>
            <compiler
                language="vb" 
                extension=".vb"
                type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"
                compilerOptions="/define:Debug=True /define:Trace=True /imports:Microsoft.VisualBasic,System,System.Collections,System.Configuration,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlControls,System.Web.UI.WebControls"
            />
        </compilers>
   </system.codedom>
</configuration>

现在一切正常。 似乎虽然原始的 web.config 文件使用了已弃用的语法,但它仍然被 IIS 6 接受,并且看起来不再被 IIS 10 接受。

无论如何,希望这对其他人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-14
    • 2020-12-20
    • 2018-10-21
    • 2011-04-13
    相关资源
    最近更新 更多