2

The w3wp.exe process is throwing the following ConfigurationErrorsException:

An error occured loading a configuration file: The process cannot access file file 'web.config' becuase it is being used by another process

Here's what we've determined so far:

  • The error is intermittant! Sometimes a refresh of the page in the browser is enough to kickstart it again. Sometimes not. The file is locked enough that we cannot open it using notepad when connected directly on the web server.
  • Because of the intermittent appearance of this error, it does not appear to be a file permission issue.
  • We have multiple applications under this exact configuration that are having this issue. They are in separate application pools. There have been no changes to the application code around the time that the errors started occuring.
  • We cannot find any processes other than the w3wp.exe that are accessing this file.
  • Our web application does not write any changes to the web.config file, only reads values from it.
  • This error is happening on multiple servers in our web farm
  • We cannot replicate this error in our development environment. It only occurs in production.
  • The application are running on x64 servers (Win 2008 Server), using the .NET 4.0 Framework.

Ideas?

Shawn H
  • 550
  • 6
  • 15
  • +1 for providing a decent set of known facts. – spender Nov 20 '12 at 16:26
  • "Our web application does not write any changes to the web.config file, only reads values from it.". It may be true for your code, buyt what about any 3rd party component? – Steve B Nov 20 '12 at 16:27
  • 1
    How does your application access the `web.config` file? Do you ever read it directly instead of using any of the classes in the `System.Configuration` namespace? – Oded Nov 20 '12 at 16:30
  • Steve B - no third party components in use. – Shawn H Nov 20 '12 at 16:32
  • Oded - Yes, we do reads using the System.ConfigurationManager.AppSettings("keyname") method. – Shawn H Nov 20 '12 at 16:33
  • Only? You never use any other method (reading `web.config` as an XML file, opening it in a file stream)? – Oded Nov 20 '12 at 16:35
  • Only access is through the AppSettings or ConnectionString Methods, no XML or File Stream access. – Shawn H Nov 20 '12 at 16:36
  • Do you perform some monitoring on System.ConfigurationManager.AppSettings, If so, does one reading get stuck just before the error is thrown ? – MLeblanc Nov 22 '12 at 03:42

1 Answers1

0

In my case the webconfig file was opened in one of the tabs of notepad++ and even the notepad++ was in closed state, once I opened and closed the notepad++ problem disappeared. This suggests checking all instances of file opening is essential.

Aditya
  • 171
  • 1
  • 5