While moving my ASP.Net application from Windows 2003 server to Windows 2008 R2 server I ran into following exception when I tried to access the application.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. To compile this Web application for version 3.5 or earlier of the .NET Framework, remove the 'targetFramework' attribute from the element of the Web.config file.
Well this took me by surprise a little because this application has been working for over a year on Windows 2003 server. I remembered that since this was child application under parent DNN portal, I had to add following entry in web.config. From being a child application means that my application was configured as another web application under DNN web application.
<location path="" inheritInChildApplications="false" >
So my first thought based on the exception details was that probably by mistake somebody removed that entry. Well that was not the case. Then I checked the application pool for parent as well as child application. They both were configured to use application pool that was using .Net 4.0 with classic pipe line. Then I looked at compiler options in my child application. It was set as follows and nothing seemed to be wrong here as well.
<compilation debug="true" targetFramework="4.0" />
Only place left was to check in parent application. After digging through million entries in DNN web.config file, I found the following that had compiler option set to V3.5.
<compiler language="vb;vbs;visualbasic;vbscript" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089" extension=".vb" warningLevel="4"> <providerOption name="CompilerVersion" value="v3.5" /> <providerOption name="OptionInfer" value="true" /> <providerOption name="WarnAsError" value="false" /> </compiler> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> <providerOption name="CompilerVersion" value="v3.5" /> <providerOption name="WarnAsError" value="false" /> </compiler>
After I changed the compiler version to V4.0, my application was happy as a pie! Here is link to Microsoft document on breaking changes that describes this issue in more detail.ASP.NET 4 Child Applications Fail to Start When Under ASP.NET 2.0 or ASP.NET 3.5 Applications