user2673097
user2673097

Reputation: 179

Creation of the virtual directory failed with error: cannot write configuration file applicationhost.config

I'm just simply trying to open up a VS 2017 project. When I open the solution, I get the following error message:

Creation of the virtual directory http://localhost:58051/failed with the error: Filename: \?\C:\Users\Visual Studio 2017\Projects\Testing\Version 2.0.vs\config\applicationhost.config Error: Cannot write configuration file

I've checked the folders along the file path and they are not encrypted. All the folders along the file path have a black box for the Read Only attribute. When I go to the config folder and clear out the black box for the Read Only attribute and Apply the setting, I find if I exit and go back to the same folder, the black box reappears for the Read Only attribute. I've read that the black box doesn't really mean the Read Only attribute has been turned on. If the Read Only attribute was actually turned on, I should expect to see a check mark instead. However, this doesn't explain why I can't open the solution.

After I click the OK Button to the VS Error message, VS just says the solution is "(unavailable)" in the Solution Explorer.

Any help would be greatly appreciated.

Upvotes: 12

Views: 17106

Answers (9)

Navdeep Kapil
Navdeep Kapil

Reputation: 381

I have resolved this error with this way mention as below:

STEP 1: Go to on that path C:\Users\navz\OneDrive\Documents\IISExpress\config

STEP2: When you reach on this folder "config" in this folder we can see "applicationhost" file

STEP3: Close the Visual studio existing project and delete the applicationhost file(see on Step 2 path)

Then open the existing project again, it will be reloaded automatically and work properly.

Upvotes: 5

bruce reeves
bruce reeves

Reputation: 1

my drives were different - but the main codebase was shared between the two machines - so on one it was in the d drive - so i mapped the parent subdirectory on the second machine to be the d drive ... which resulted in the same paths then on both ... i just had to open the solution from the d drive on the second machine

Upvotes: 0

David Morrow
David Morrow

Reputation: 294

Had same problem then looked into vs\config\applicationhost.config and it was encrypted. I unencrypted file and solution loaded with no problems.

Upvotes: 3

Steve Greene
Steve Greene

Reputation: 12304

Windows 10 Defender was causing this for me. When I disabled control folder access it worked again. Odd, because it had been working with that setting on for a while.

Upvotes: 0

Brian Knoblauch
Brian Knoblauch

Reputation: 21369

None of the above worked for me. I ended up deleting and recloning the repo that was giving me problems. It then opened up just fine.

Upvotes: 0

Mark G
Mark G

Reputation: 597

I've had this problem several times using VS 2017 with Onedrive. Resolved it by renaming the application.config and having VS recreate it. Just as well could have edited line in the file. See the Diff below as an example.

Image showing diff between original and recreated applicationhost.config

The config file is located in something like C:\Code\MyProject\.vs\config\.

Upvotes: 2

Warren R
Warren R

Reputation: 221

I too had this problem with my project files located on OneDrive. The way I resolved it was I renamed the applicationhost.config file located in the ".vs\config" directory of your root project directory then reloaded the web project. This will create a new applicationhost.config file.

Upvotes: 19

Ryan Buddicom
Ryan Buddicom

Reputation: 1151

I just encountered this error. I followed the steps in this answer: https://stackoverflow.com/a/50508207/1166163

When I tried to save my changes I realised TFS had marked the file as read-only, preventing VS from updating the value. Removing the read-only attribute fixed the problem.

Upvotes: 0

user9840475
user9840475

Reputation: 79

I had the same error message sharing a project between 2 machines via OneDrive and fixed it as follows:

1 - Closed VS.Net

2 - Opened [myappnamefolder].vs\config\applicationhost.config in Notepad

3 - Searched the open file for the filename in my error message (In your case C:\Users\Visual Studio 2017\Projects\Testing\Version 2.0.vs\config\applicationhost.config ).

It was found under system.applicationHost, sites, site name, application path, virtualDirectory - physicalPath

4 - Amended the physicalPath value to point to the valid path of the project's config file as above.

5 - Saved the applicationhost.config file

My paths were different because I had different home user directories on each machine. (User A & User B)

Upvotes: 7

Related Questions