IIS express: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to

Prasath Siva picture Prasath Siva · Aug 29, 2013 · Viewed 82.9k times · Source

In Visual studio, Solution->Web.Project->Properties->Web, I have changed my Project Url from http://localhost:51123/ to http://localhost:51123/NewProjectName and I keep getting this error:

"Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to ...." on every module added.

Adding a remove tag works but then it should have been a problem even before i changed the url. Any suggestions?

Answer

orjanto picture orjanto · Aug 30, 2013

I think IIS Express probably has 2 <application>-blocks and both will be pointing to the same physicalPath.

Go to the IIS Express config file in: My Documents\IISExpress\config\applicationhost.config

Search for NewProjectName

Change the physicalPath for the root application to something else. Point it to an empty folder.

Should look something like this:

<site name="NewProjectName" id="1">
  <application path="/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="c:\Temp" />
  </application>
  <application path="/NewProjectName" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="c:\sourcecode\NewProjectName" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:51123:localhost" />
  </bindings>
</site>