ConfigurationErrorsException due to targetFramework mismatch

Posted by

This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.


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)


Check #1:

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.).


Check #2:

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.

  1. Open RegEdit on the problematic machine
  2. Navigate to this location:

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:

  • Repair the .NET Framework installation
  • Open a support case for .NET Framework installation (the missing stuff is not specific to ASP.NET - it's .NET Framework setup-related stuff)
  • Export/Import the missing SKUs from a machine that has no issues (ideally a machine that is setup the same way). If you do this, I strongly recommend you only copy SKUs for what the machine actually has. You can use the link in Check #1 above to verify what version of .NET Framework is installed, then add the SKUs up to and including that version only (i.e., don't add the SKU for 4.8.1 if the server has 4.8).


More info:

Here's where the targetFramework attribute is parsed from the web.config file:,0b68e167ec0a1dbe,references


Here's where the actual validation of the targetFramework attribute is performed in ASP.NET:,0395be3b0b50c6d4

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.