.NET Developers often face this issue when they use the existing project or add existing project into another new solution. In my case, I faced this issue while adding existing project into another solution. Whenever, I run the project, I get this error message.

The exact error is shown below:

Failed to register URL “http://localhost:49239/” for site “ProjectName” application “/”. Error description: The process cannot access the file because it is being used by another process.

We can also face issue like as shown.

Both these error are related with same.

Reason for this error.

The main cause for this error is the port is already being used by another project.

The error code 0x80070020 means ERROR_SHARING_VIOLATION. In other words, our IIS Express or IIS port that it is attempting to listen on is being used by another process.

Solution

We can resolve this issue several ways.

Solution 1: You can change the port number.

Steps:

  1. Right click on the project and select Unload Project
  2. Again right click the project and select Edit the project, ProjectName.csproj
  3. Search for these three lines
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:62940/</IISUrl>

4. Remove these 3 lines

5. Save and reload the project.

After doing this, your project will be assigned with new port which is not in use.

Solution 2: You can check and verify the port which are in used.

We can use netstat to find the application using the port as shown.

netstat -ao | findstr <port_number_to_search_for>

The a parameter tells netstat to display all connections and listening ports.
The o parameter tells netstat to display the process ID associated with the connection.

Output of this command.

Then you can identify the application using same port and modify accordingly with solution 1.

Regards

Rijwan

By Rijwan Ansari

MVP, CSM, CSPO, MCP, MCTS. Sr. Software Developer. Expertise in ASP.NET MVC, Angular, AngularJs, .Net Core, C#.NET, Azure, Cognitive Services, Machine Learning, SharePoint, Azure Services, and tools, Requirement Analysis, Team Management, Pre-Sales and more. Ability to work independently and Team, handle pressure and meet commitment. Excellence Communication and adjust in any environment

Leave a Reply

Your email address will not be published. Required fields are marked *