.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

Research and Technology Lead | Software Architect | Full Stack .NET Expert | Tech Blogger | Community Speaker | Trainer | YouTuber. Follow me @ https://rijsat.com Md Rijwan Ansari is a high performing and technology consultant with 10 plus years of Software Development and Business Applications implementation using .NET Technologies, SharePoint, Power Platform, Data, AI, Azure and cognitive services. He is also a Microsoft Certified Trainer, C# Corner MVP, Microsoft Certified Data Analyst Associate, Microsoft Certified Azure Data Scientist Associate, CSM, CSPO, MCTS, MCP, with 15+ Microsoft Certifications. He is a research and technology lead in Tech One Global as well as leading Facebook community Cloud Experts Group and SharePoint User Group Nepal. He is a active contributor and speaker in c-sharpcorner.com community, C# Corner MVP and his rank at 20 among 3+ millions members. Additionally, he is knee to learn new technologies, write articles, love to contribute to the open-source community. Visit his blog RIJSAT.COM for extensive articles, courses, news, videos and issues resolution specially for developer and data engineer.

Leave a Reply

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