Home » IIS » Unexpected end of file has occurred (There was an error while performing this operation)

Unexpected end of file has occurred (There was an error while performing this operation)

We use IIS Manager to manage the websites hosted in the web server. What if IIS Manager crashes as soon as you open it? In my case: It showed this error message: There was an error while performing this operation. Unexpected end of file has occurred

Full error message:

There was an error while performing this operation

Filename: C:\windows\system32\inetsrv\config\applicationhost.config
Line number: 1026
Error: Unexpected end of file has occurred. The following elements are not closed: modules, system.webServer, location, configuration. Line 1026, position 252

There was an error while performing this operation - Unexpected end of file has occurred
IIS Manager crash

Solution for the “Unexpected end of file has occurred” error

I like how much details are there in the error message. It tells you which line number (Line 1026) in which file (applicationHost.config) has the issue and what the issue is (modules, system.webServer, location, configuration elements are not closed).

When I looked into the file, I saw that the file was actually cut off at the line 1026. There was nothing else afterwards. Thinking about the issue history (It started occurring after building this server from a virtual machine disk copy), It’s not hard to guess that something went wrong while copying this file.

You can solve this issue by;

  • Manually editing the config file (For example: If an element is missing a closing tag, you can add that tag manually)
  • Copying the config file from backup, if you have one
  • Restoring the virtual machine (Again, if you have backup)
  • If there is another server with the same sites and configuration, compare the files and copy/paste the missing lines
  • Reinstall IIS and create sites from scratch (Last resort)

If none of these solutions works, check out this post to find out the other common reason config file related IIS Manager crash: The configuration section rewrite/globalRules cannot be read because it is missing a section declaration

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.
Categories IIS

Leave a Comment