Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 909
user2673097 Avatar asked May 11 '18 21:05

user2673097


5 Answers

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

like image 52
David Morrow Avatar answered Oct 24 '22 14:10

David Morrow


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\.

like image 37
Mark G Avatar answered Oct 24 '22 12:10

Mark G


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.

like image 37
Navdeep Kapil Avatar answered Oct 24 '22 14:10

Navdeep Kapil


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.

like image 23
Warren R Avatar answered Oct 24 '22 13:10

Warren R


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)

like image 38
user9840475 Avatar answered Oct 24 '22 13:10

user9840475