How do I fix the "compilerVersion" IIS error?

asp.netIis.Net 4.0

asp.net Problem Overview


I'm getting this exception:

> System.Configuration.ConfigurationErrorsException: The value for the > 'compilerVersion' attribute in the provider options must be 'v4.0' or > later if you are compiling for version 4.0 or later of the .NET > Framework.

What should I do to resolve this?

asp.net Solutions


Solution 1 - asp.net

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:

Solution 2 - asp.net

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>

Solution 3 - asp.net

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>

Solution 4 - asp.net

Remove this section from web.config

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

Solution 5 - asp.net

In my case it was a child site under the Default Website and although the default website settings were set at ASP.NET 4.0, the web.config file was set for 2.0 and 3.5. Changing the web.config file to use 4.0 fixed it. Use this for reference: [ASP.NET 4 Breaking Changes][1]

[1]: http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes#0.1__Toc256770150 "ASP.NET compiler version error"

Solution 6 - asp.net

We had accidentally copy-pasted Web.config into C:\inetpub\wwwroot. This accidentally copy-pasted Web.config had mismatching configuration and caused the compilerVersion error for us. Deleting the Web.config solved the problem for us.

Solution 7 - asp.net

In my case, I am using an old Webform website (V 2.0), need to append a new application which is developed in MVC4.0. This same error I was facing and after many permutations and combination of the given solution, I wrapped the whole web.comfig of the parent application in the following tag

<location path="." inheritInChildApplications="false">
...... web config tags here........
</location> 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonathan AllenView Question on Stackoverflow
Solution 1 - asp.netJohn KView Answer on Stackoverflow
Solution 2 - asp.net4igiView Answer on Stackoverflow
Solution 3 - asp.netJames LawrukView Answer on Stackoverflow
Solution 4 - asp.netJonathan AllenView Answer on Stackoverflow
Solution 5 - asp.netMarlonView Answer on Stackoverflow
Solution 6 - asp.netMtqView Answer on Stackoverflow
Solution 7 - asp.netHaritusView Answer on Stackoverflow