Microsoft releases Windows updates every second Tuesday of the month. Most of the time, these updates require a restart. Therefore, you may see some unexpected behavior the very next day of the updates and restart. The issues are not necessarily caused by Windows updates. Sometimes, a past configuration change takes effect after the updates because the machine is restarted.Read More
If you have a website traffic that is more than one web server can handle, it’s a good idea to scale your environment up by adding new servers. IIS supports sharing the configuration and data across multiple servers. However, you may come across “Configuration file is not well-formed XML” error in certain situations.
This error message is one of the indicators that IIS shared config environment is having difficulties obtaining and syncing the data. Another indicator is the Access to the path is denied error. The main symptom is that application pools stop after making a change to IIS configuration.
“Configuration file is not well-formed XML” message and other related errors show up in the Event Viewer within different IDs. Make sure to check both System and Application containers to have a bigger picture of the issue.
Here are the a few examples of this error message (event ID: error description):
15000: Unable to create log files on shared file server.
5053: The Windows Process Activation Service received a change notification, but was unable to process it correctly. The data field contains the error number.
5172: The Windows Process Activation Service encountered an error trying to read configuration data from file applicationHost.config line number 0. The error message is: ‘Cannot read configuration file’. The data field contains the error number.
30: The FTP Service encountered an error trying to read configuration data from file applicationHost.config, line number 0. The error message is: Cannot read configuration file. The problem occurred at least 1 times in the last 5 minutes. The data field contains the error number.
9006: The Application Host Helper Service encountered an error trying to process the configuration data for config history. The feature will be disabled. To resolve this issue, please confirm that the configuration file is correct, has correct attribute values for config history and recommit the changes. The feature will be enabled again if the configuration is correct. The data field contains the error number.
2307: The worker process for application pool abc.com encountered an error ‘Configuration file is not well-formed XML’ trying to read configuration data from file abc.config, line number 3. The data field contains the error code.
2297: The worker process for application pool abc.com encountered an error ‘Configuration file is not well-formed XML’ trying to read global module configuration data from file abc.config, line number 3. Worker process startup aborted.
Solution for “Configuration file is not well-formed XML” error
As mentioned in this article, DFS (Distributed File System) deletes the current config file and create a new one when there is a change in the IIS shared configuration environment. During this deletion/creation process, it is possible that a member server fetches the incomplete config file.
Change the value of the
ConfigPollMilliSeconds parameter to 600000. This will tell IIS not to rely on file system change notifications and automatically check the last modified date of the configuration file every 600000 milliseconds (10 minutes).
The default value for this registry key is 0. When this value is set to 0, the ConfigPollMilliSeconds parameter is disabled. The configuration system relies on change notifications to track changes to configuration files. A positive value for this key indicates that the configuration system checks the last modified time of the configuration file for every N milliseconds. The configuration system does not use the directory monitors.Microsoft Support
The registry key:
Make sure to restart the server after changing the value of this registry key.
If the first solution doesn’t work, you may want to try enabling Offline Files for the shared folder. The instructions are below. If it is production environment, please make sure to implement this change out of business hours and monitor the system for a while to see if changes are synced and websites are served successfully
- On the Web server, in Control Panel, open “Offline Files”
- In the Offline Files dialog box, click “Enable Offline Files”. Do not reboot the machine yet
- Ensure that the cache is set to read only by running the following command in Command Prompt:
REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v ReadOnlyCache /t REG_DWORD /d 1 /f
- Restart the web server
- Go to the file share folder from web server. Right click and select “Always Available Offline”
- Go to “Control Panel > Offline Files”. Select “Schedule” option
- Schedule offline file sync
I would recommend backing up the content of the temporary application pool folder (C:\inetpub\temp\apppools\) and then emptying it. IIS may have already stored the corrupted config files before you made the change in registry. Restart application pool(s) after removing the content of this folder.
Windows updates may cause “Configuration file is not well-formed XML” error as well. Check the latest updates you have installed. Uninstall them if to test if the issue is related to these updates. Here is a way to list Windows updates: How to list all Windows updates easily
Still getting the error?
Offline Files and
ConfigPollMilliSeconds approaches are worth to try but they don’t guarantee a seamless synchronization especially when there network and storage related issues, unfortunately.
If you come across to this issue only during Windows Server monthly patches, try the procedure below to update your servers. It will add more workload to your patch process but you will have less problems:
- Break the shared config (make the config local in every node)
- Patch the servers
- Re-establish the shared config
If you see an error related to
NetFx40_IIS_schema_update.xml file, check this post for the solution: Windows Process Activation error (NetFx40_IIS_schema_update.xml)
Web farm with a shared content but without shared configuration
Another option is that using a Web Farm with content on the storage server but the configuration is local to each server. This will require changing your setup but it offers smoother patch cycles. There is a comprehensive document for planning and setting up a Web Farm. It was written for IIS 8 but it is applicable to newer versions as well: Build a Web Farm with IIS Servers
As you will see in the Planning Step 1, there are two Web Farm types:
- Local Content Infrastructure (Uses local content, local configuration)
- Shared Network Content Infrastructure (Uses shared content, shared configuration)
The document covers the steps for setting up a Shared Infrastructure which uses a network share for both content and configuration. As you have been having issues with the shared configuration, I would recommend executing the steps for the shared content but skipping the shared configuration part which is Configuring Step 2.3.
Note: The document doesn’t explain how to mirror your file server to avoid single point of failure for the shared content. This is something you should be think about to prevent file server related issues.