The error "Cannot create/shadow copy 'XXX' when that file already
exists" can occur when you try to run or debug an ASP.NET application.
If you search the web you'll find various causes and solutions to this
error. I would like to add a new and unusual circumstance for
posterity.
My application uses its own logging mechanism that writes log messages
to a plain text file. It also allows the location of the file to
specified as part of the configuration process. If the log file
location is set to the bin directory of the web application, this
error can occur along with a number of other unusual behaviors. These
behaviors include: It takes 30 to 60 seconds for the web page to load;
If the page loads successfully, postback events are not seen by the
web app (e.g., if you have a login page, the click event for the login
button never shows up in the handler, although you do see the page
being constructed and initialized).
The problem appears to be that IIS is monitoring the bin directory for
the change of any file. If any file changes, he feels compelled to
reload all the DLLs all over again. In the case of my app, evertime a
log message was written at the initialization phase of the lifecycle,
all the dll's in the app (about eight of them) were being reloaded.
Anything having to do with copying files got into a royally undefined
state -- hence our error.
Best of luck.
--Phil
|