FIX: ASP.NET/IIS applications may fail to load when web.config file of the application is overridden by using Configuration.Save(…) or Configuration.SaveAs(…) methods in the .NET Framework 4.7

Applies to: .NET Framework 4.7

Symptoms


When developers use Configuration.Save(..)/Configuration.SaveAs(..) methods in Microsoft .NET Framework 4.7 to save/override web.config file of an ASP.NET/IIS (Internet Information Server) application, they may notice that a new empty Windows Forms application specific section <System.Windows.Forms.ApplicationConfigurationSection> is being added to web.config file and their application may fail to reload.

Cause


While adding HDPI ( High Dots Per Inch) support for Windows Forms applications in the Microsoft .NET Framework 4.7, Windows Forms team has introduced a new configuration section <System.Windows.Forms.ApplicationConfigurationSection> in the application configuration (app.config) file through which developers can customize applications for HDPI specific features.

This new section is currently used only for Windows Forms applications and to customize HDPI features that are only added in Microsoft .NET Framework 4.7. Therefore, declaration of this new section happens at runtime and in Windows Forms applications only (as opposed to a general practice of declaring it in machine.config file). When developers use Configuration.Save(..)/Configuration.SaveAs(..) methods, they see an empty definition of this runtime declared section being added to the configuration file that's being Saved/Created/Overridden. When a non-Windows Forms application (ASP.NET/IIS) is reloaded with this newly Saved/Created/Overridden config file, the application may fail to reload because of missing declaration of the section.

Resolution


Developers/Users can safely remove this empty section <System.Windows.Forms.ApplicationConfigurationSection> definition from web.config file (it is not consumed by any other applications other than Windows Forms User Interface) and try reloading their application. Removal of this empty section from the file has no effect on functional behavior of the application.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section and Microsoft is working on solution in the upcoming versions of the product.