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.
Remove this section from web.config
<compilation debug="true" strict="true" explicit="true" targetFramework="4.0" />
I had a similar or same problem (unsure) recently and had to tell ASP.NET to use the 3.5 compiler when compiling stuff at runtime like so by modifying Web.config
. This is different than the explicit compile (i.e. in Visual Studio) that is usually performed on a web app.
This is copied and pasted form my code - you would have to change value="v3.5" to value="v4.0" I suspect. The compiler type strings might also have to change but at the moment I don't have that info for 4.0.
<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 the 3.5 compiler. IIS 7, ASP.NET Website project.
If it's not the same problem then maybe this piece of code will be useful here for posterity. However if this works for your situation you might glean additional insight from: