How do I fix the "compilerVersion" IIS error? How do I fix the "compilerVersion" IIS error? asp.net asp.net

How do I fix the "compilerVersion" IIS error?


I had a similar problem and had to tell ASP.NET in configuration to use the 3.5 compiler as follows by modifying Web.config.

I've copied and pasted the following from my code. You have to change value="v3.5" to value="v4.0". The compiler type strings might also change.

<configuration>  <!--  ... other configuraiton stuff ... -->  <system.codedom>    <compilers>      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">        <providerOption name="CompilerVersion" value="v3.5"/>        <providerOption name="WarnAsError" value="false"/>      </compiler>      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">        <providerOption name="CompilerVersion" value="v3.5"/>        <providerOption name="OptionInfer" value="true"/>        <providerOption name="WarnAsError" value="false"/>      </compiler>    </compilers>  </system.codedom></configuration>

In my case the 2.0 compiler was being used instead of 3.5. I was working in an IIS 7, ASP.NET Website project.

You might glean additional insight from:


this should help

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


In my case, I was trying to run a child application using 4.0, but the parent application needed to still use 2.0. Wrapping the compilers information in the parent web.config with a <location path="." inheritInChildApplications="false"> tag fixed it.

Parent Web.config:

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