If you are experiencing this exception:
Exception type: ConfigurationErrorsException
Exception message: The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, '<compilation targetFramework="4.0">'). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework. (c:\path\to\web.config line ###)
at System.Web.Compilation.MultiTargetingUtil.ValidateTargetFrameworkMoniker(String targetFrameworkMoniker)
at System.Web.Compilation.MultiTargetingUtil.InitializeTargetFrameworkName()
at System.Web.Compilation.MultiTargetingUtil.EnsureFrameworkNamesInitialized()
at System.Web.Compilation.BuildManager.Initialize()
at System.Web.Compilation.BuildManager.InitializeBuildManager()
at System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException)
First thing to do is a sanity check to make sure the version of .NET Framework the machine has installed is the same or greater than what the system.web/compilation targetFramework attribute is set to. This documentation shows how to determine which .NET Framework versions are installed (i.e. if the app is targeting 4.8.1 make sure 4.8.1 is installed, etc.).
If the machine has the appropriate .NET Framework version installed but you are still experiencing the error, then you can follow the below steps to check why the exception is occurring.
Within the last ~1yr or so, as of this writing, our team has come across a few support cases where the above error is occurring because that "SKUs" key is either missing or empty (usually missing). If that is the case, you have few options:
More info:
Here's where the targetFramework attribute is parsed from the web.config file:
Here's where the actual validation of the targetFramework attribute is performed in ASP.NET:
https://referencesource.microsoft.com/#System.Web/Compilation/MultiTargetingUtil.cs,0395be3b0b50c6d4
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.