3

We are deploying our ASP.Net MVC application to a windows 2008 R2 server, running IIS 7.5.

After deployment, we get this error in the event log (we also get an email) : "Unrecognized element 'providerOption'" on line x in c:\wwwroot\web.config which is:

<providerOption name="CompilerVersion" value="v3.5"> 

located in the system.codedom compiliers section of our standard web config. I investigated the problem a bit. (I also checked the namespace details on msdn to find out abit about it). Amongst many other solutions, I found this post recommending updating the FX_Schema.xml file on our server. (I think this is where the problem is, please correct me if I'm mistaken)

I looked through fx_schema file, and, as defined in the event viewer, the attribute "providerOption" is not in this schema! Here is the copy of the system.codedom section from the FX_schema.xml

<sectionSchema name="system.codedom">
    <element name="compilers">
        <collection addElement="compiler" removeElement="remove" clearElement="clear">
            <attribute name="language" type="string" isCombinedKey="true" />
            <attribute name="extension" type="string" isCombinedKey="true" />
            <attribute name="type" type="string" />
            <attribute name="warningLevel" type="int" />
            <attribute name="compilerOptions" type="string" />
        </collection>
    </element>
</sectionSchema>

I am sure that I can not be the the only person who has this problem, but has anyone else anyone come across this before and found a solution?

EDIT: Another way to produce this quickly is (on IIS 7 in Windows 7)

In IIS Managment console, open your MVC website, in the website home. You should see ASP.NET, IIS, and Managment groups. Under Management, open the "Configuration Editor". I get the error message popping up here!

EDIT: My copy of the web config:

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
            type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
         <providerOption name="CompilerVersion" value="v3.5"/>
         <providerOption name="WarnAsError" value="false"/>
    </compiler>

  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
            type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
      </compiler>
   </compilers>

</system.codedom>

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Dai Bok
  • 3,451
  • 2
  • 53
  • 70
  • no one gonna help me here? might have to wait for the next windoes update.... :-( – Dai Bok Nov 19 '10 at 16:42
  • Could not solve this problem easily, looks like the only way is to upgrade our project to .net 4, which will take some time. I have accepted brians work around until I find a better solution. – Dai Bok Dec 01 '10 at 17:26

2 Answers2

1

I've managed to recreate the error in IIS by simply going to the system.codedom section of the configuration manager.

I don't get any error using either a .net3.5 or .net4.0 app but these are very basic test apps, also only .net3.5 test apps put a system.codedom section in the web.config file by default. .net4.0 simplified the web.config file and moved out a lot of options

I've found some information here about possible config conflicts which may be of use

It recomends

The workaround for the second scenario is to delete or comment out all the system.web.extensions configuration section definitions and configuration section group definitions from the application-level Web.config file. These definitions are usually at the top of the application-level Web.config file and can be identified by the configSections element and its children.

For both scenarios, it is recommended that you also manually delete the system.codedom section, although this is not required

Not exactly the same problem but similar

  • Yip, the file is autmatically genereated when you make a new MVC project. I haver not editied. If you make a test MVC project, do you getthe same error? – Dai Bok Nov 26 '10 at 12:58
  • thanks for the help brian, but I still could not get this working. While deleting the system.codedom section will, in no doubt, validate the web.config according to the schema. But the fact the the MVC 2 (with .net3.5) project generates the web.config code automatically for me, I like to to think of this as a little bug. Basically, someone forgot to validate the web.config for this version of the project against the schema. :( – Dai Bok Dec 01 '10 at 17:32
0

I had an issue very similar to this that I posted and then solved myself and posted the solution I came up with. My solution: I made my own file and placed it in with the schema files. I called it the inventive name ThreeFive.xml and placed it at C:\Windows\System32\inetsrv\config\schema. The entire contents of the file are as follows:

<configSchema>
    <sectionSchema name="system.codedom">
        <element name="compilers">
            <collection addElement="compiler" removeElement="remove" clearElement="clear">
                <attribute name="language" type="string" isCombinedKey="true" />
                <attribute name="extension" type="string" isCombinedKey="true" />
                <attribute name="type" type="string" />
                <attribute name="warningLevel" type="int" />
                <attribute name="compilerOptions" type="string" />
                <collection addElement="providerOption">
                  <attribute name="name" required="true" isUniqueKey="true" type="string" />
                  <attribute name="value" required="true" type="string" />
                </collection>
            </collection>
        </element>
    </sectionSchema>
</configSchema>

I then published a 3.5 site that retrieved information from an appconfig setting and did some LINQ to make sure the config and the 3.5 were in effect. The config file was not blanked and the LINQ is working as expected so I am tempted to call this a solution.

Community
  • 1
  • 1