We are trying to solve a rather perplexing error in an ASP.NET application (DNN / DotNetNuke) after upgrading our webservers from the EOL Windows Server 2012 R2 to 2022 (currently experiencing the error on 2016). We upgraded the testing server successfully with no issues but the production server (which the testing server is an exact clone of) is giving us the error in the screenshot here below. In web.config the targetFramework="4.7.2" is failing even though we have 4.7.4076.0 installed as shown at the bottom of the screenshot. Has anyone experienced this before or familiar with a potential fix?
If I remove the targetFramework="4.7.2" compilation option in the web.config, the site runs fine, but I would prefer to address the root cause of IIS not recognizing that the 4.7.4076.0 that it is currently exceeds the 4.7.2 minimum target.
Thanks in advance.
If you encounter a ConfigurationErrorsException due to targetFramework mismatch:
The first thing to do is to do a sanity check to make sure the computer has the same or higher version of the .NET Framework installed as the version set by the system.web/compilation targetFramework property. The version indicated on the error page (4.7.4076.0) is actually the ASP.NET version, which is different from the Framework version.
This document demonstrates how to determine which .NET Framework versions are installed (i.e., if your application targets 4.7.2, make sure 4.7.2 is installed, etc.). One thing to check is the actual version installed:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
For 4.7.2, the value of the Release key should be 461814.
If your computer has the appropriate version of .NET Framework installed and you are still encountering this error, you can follow the steps below to check why the exception occurred.
HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKU
If it's because the "SKU" key is missing or empty (it's usually missing), it's recommended that you repair your .NET Framework installation.
For more information, please refer to this article: ConfigurationErrorsException due to targetFramework mismatch