Search code examples
asp.net-mvcvisual-studio-2015web-configiis-expressrenaming

A Renamed WebSite, Web.Config, Log4Net, using IIS Express, using Git version control, in VS2015, failing


So this was quite a hilarious error and was quite difficult to trace, so I'm going to chuck everything on here in case it happens to anyone else;

While working on a website in production, its name changed. I noticed that the IISExpress instance displayed not only the new name, but a '\' and the old name as three separate instances.

As I was attempting to add log4net to the project, I attempted to use this line in the web.config:

<log4net configSource="log4net.config" />

Which caused the following error on app run:

the configSource file '[file]' is also used in a parent, this is not allowed.

the configSource file is also used in a parent, this is not allowed.

This was perplexing as I had not used this source anywhere else, and no matter what file I changed it to, I got the same error.

log4Net worked fine when I defined it entirely within my web.config, but that's not what I wanted, so I investigated further. Interestingly, a colleague who'd just been brought onto the project could run the app fine with the separated config, but I and another dev who'd been working on this project for a while could not.

How can I and another colleague with exactly the same setup have a failing app with the same config as someone with a fresh checkout have it work fine?


Solution

  • It turned out to be that IISExpress had saved the previous settings in a .vs folder at solution's root level, and all three of those instances were using the same config, and looking for the same file, hence the error.

    The solution was as follows:

    1. In the web-app's project, reset the web properties to look at the root site (\ instead of \newname\)
    2. Trash the entire .vs directory
    3. Restart Visual Studio and Reload the project.

    For different versions of VS, the .vs folder is in different locations on your machine.