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

别等时光非礼了梦想. 提交于 2019-12-21 09:25:46

问题


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.


回答1:


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.




回答2:


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)




回答3:


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.

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




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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 again existing project it will reload automatically and work proper.




回答8:


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




回答9:


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



来源:https://stackoverflow.com/questions/50300675/creation-of-the-virtual-directory-failed-with-error-cannot-write-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!