Search code examples
asp.netvb.netiiswindows-server-2016

Unrecognized element 'compilers' with old asp.net app on IIS 10.0


I’m hoping that someone will be able to help we with an IIS / ASP.NET issue that I’m having. I’ve been tasked with moving an ASP.NET website from IIS 6 on a Windows 2003 32-bit server to IIS 10 on a Windows 2016 64-bit server. I’ve installed IIS and the .NET 3.5 Framework which includes .NET 2.0 and 3.0 using PowerShell with the following features

$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

Next created my application pool and site as follows

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

The site seems to load the login page, however in IIS Manager, if I go to .NET Compilation I receive the following error message. There was an error while performing this operation.

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

Here is an expert on the web.config file

    <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>

I have tested the Application Pool with the managed pipeline mode set to Integrated and Classic, and have also test setting Enable 32-Bit Applications to True, but I still get the same error.

I read online that is possible to get this type of error if IIS is installed before installing .NET 3.5 Framework, so I uninstalled both using server manager rebooted, the installed .NET 3.5 Framework and rebooted and installed IIS, but I still get the same error.

I’ve also tried running aspnet_regiis.exe -i from the two following folders, but again I still received the same error.

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

If anyone has any suggestions on how to correct this issue I would be really grateful.

Thanks


Solution

  • So I did some more diging around and finally figured out the issue.

    According to Microsoft the compilers element under compilation element was depreciated in .NET framework 2.0, but was still supported. It ends up that I place the compilers and compiler elements under the system.codedom element

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

    So now instead of this

    <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>
    

    I have this

    <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>
    

    And everything works now. It seems that although the original web.config file was using depreciated syntax, it was still accepted back with IIS 6, and looks like it is no longer accepted with IIS 10.

    Anyway, hope this helps someone else out.