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

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.

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.

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)

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.

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

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

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.

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.

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.

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

Related

C++ Windows Driver MSB3030 could not copy the file '' because it was not found

VS2017, SDK/WDK, C++ project
we have a c++ solution (driver) that is shared across developers via Team Foundation Services - visualstudio.com (now called azure devops?).
When I perform a get latest source code, and want to rebuild the solution I get two MSB3030 errors:
"Could not copy the file "C:\path of my colleague his file" because it was not found."
I found it strange that I saw on one of the two errors a path of my colleague his pc. He works on C:\ I'm working on E:\
Unloading the project, I saw he path being set here:
<ItemGroup>
<FilesToPackage Include="C:\path of my colleague\foo.xml" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PackageRelativeDirectory>
</PackageRelativeDirectory>
</FilesToPackage>
We cannot get this solution to build because of the MSB3030. First we have to clean the specific projects individually, rebuild it, then build another project etc.. a few steps to perform manually in the correct order , trial and error, drinking coffee, throwing bananas to the pc and praying that a monkey outputs the code correctly.
Has anyone seen somehting similar regarding MSB3030 errors?
On my pc I see the path of my colleague, but he doesn't see my path (strange!).
C:\Program Files (x86)\Windows
Kits\10\build\WindowsDriver.common.targets(1699,5): error MSB3030:
Could not copy the file 'C:...' because it was not found.
I've set the Any CPU to x64 because it doesn't make any sense for c++.
C++ Windows Driver MSB3030 could not copy the file '' because it was not found
The reason for this issue is that the path of the ItemGroup is an absolute path in the project file:
<ItemGroup>
<FilesToPackage Include="C:\path of my colleague\foo.xml" ...>
...
</FilesToPackage>
</ItemGroup>
Regardless of whether your colleague has added this file to source control, when you pull the code from the TFS server to your local and put the code in a different local folder, the absolute path will bring you a lot of trouble, you need to manually check the code on the TFS server for this file and you need to modify the absolute path of this file in your project. But this problem will reappear after your colleague updates after you submit your code. Because an absolute path cannot be assigned to two different paths C:\ and E:\.
To resolve this issue, you need to change the absolute path to a relative path in the source code. Generally, we prefer to add this file to the Solution/Project folder, then use the MSBuild Macros $(SolutionDir)/$(ProjectDir) to specify it.
Check Common macros for build commands and properties for some more details.
Hope this helps.

Cant open html resource file using ifstream::open - Visual Studio 2013

I am working on a project which requires me to open an HTML file and use its contents. I added it to Resource files but when I try to open it lie this:
std::ifstream templateFile;
templateFile.open("filename.html", std::ifstream::in);
The operation fails. I checked it by using templateFile.fail().
The above operation works when I provide the full path. The file lies in the project folder along with other files. I tried setting build action to content but still it doesnt work. Please Help.
Output directory, where your executable is compiled and put into differs from the source directory, where you create all your .cpp/.hpp files (I assume there is filename.html file). Local path filename.html is supposed to be local for your executable file, not the source file.
Read more about changing the output directory here: https://msdn.microsoft.com/en-us/library/ms165410.aspx
Under Configuration Properties / Debugging, see what your Working Directory is using the macros dialog box. Move your file into this folder.
Click the button shown in the figure. There, click either Edit or Browse. Browse will take you to the working directory. Edit will expose the link to open the macros box

Cannot save file in WebStorm 9

I have been using the same workflow for months to add a new page in my ASP .NET site, but all of a sudden I am getting problems with trying to save a .ascx file inside of WebStorm.
I created the .ascx page in VS and then saved it. I then go over to WebStorm to start developing and I cannot save any of these new files. I get this error:
Following errors occurred on attepmt to save files:
C:\...\Management\Management.ascx___jb_bak___ (Access is denied)
I don't get what this file is and why it can't be saved... The jb makes it seem like a JetBrains file, but this file doesn't actually exist in the filesystem. All the other files I have had work just fine. Its just this new file all of a sudden.
What does this error even mean.. there is no valuable information
This error happened to me everytime I used Nodemon to start Webpack on a separate process. The problem was fixed by disabling "Safe write" in "Settings", as VyvIT suggested.
Hello to Developers using Jetbrains products!
I had this problem today and I think it was for the webstorm but I check my E: drive that I was developing on.
The problem was with my hard drive that changed to read-only.
I changed my drive to C and it solved.
Check your drive that you are using. That might be the problem.
You need to change your security options for user in Windows:
Right Click
The Folder > Properties > Security Tab
Click on
Edit to change Permissions > Select User

Not able to save file deployed on jetty server

I have deployed my webapplication on a jetty server, and I am trying to edit those deployed files using WebStorm 8.0.4. But I am unable to save the edited files and getting the following error:
Try turning the 'safe write' feature (Settings/General, 'Use safe writes') off - does it help? It creates a temporary copy of a file: creates a separate temp file, deletes the original and then renames. With this option the original file permissions may be lost, this causes problems, especially when working on remote drives.
Follow these steps.
Open C:\Users\YourUserName\.m2\repository (If you use maven)
Find org folder and Navigate org\eclipse\jetty\jetty-webapp\yourJettyVersion
There will be a .jar file.
Open it with winrar or some program like winrar.
Navigate org\eclipse\jetty\webapp
Find webdefault.xml and Open it with any text editor.
Search useFileMappedBuffer parameter in file
You will see a param value.
Change it to false.
Save and Exit.
I'm sorry for any English mistakes.

"Error C1083: Cannot open source file" Shouldn't Be Looking For The File At All

I was trying to #include a cpp file with some functions so I can use that cpp file later with other projects. It gave me an 'already defined in .obj' error and since then that .cpp file was like binded with my project. (I understood that's not the way, the answer here helped me with the already defined)
If I exclude the .cpp file from the project, remove it from the directory and remove the #include line it still looks for it:
c1xx : fatal error C1083: Cannot open source file: 'std.cpp': No such file or directory
Diagnostic:
Outputs for D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\CBMAIN.CPP|D:\MY DOCUMENTS\C#\PROJECT\D3DTESTC++\COWS AND BULLS\STD.CPP: (TaskId:15)
It shouldn't be looking for the std.cpp at all, I removed it! So is there a way I can reset the project and recompile so that the program doesn't look for it? I already tried Rebuild and Clear -> Build Project
When I ran across a similar problem with VS Express, I wound up having to open up the the .vcxproj file (which is just XML), and remove the offending
< ClInclude Include="FILEPATHANDNAME" > tags.
Many of the solutions here will not work
Fullproof method:
Open the vxproj file that is giving you trouble in a text editor.
remove all references to the file it cannot find.
OK, I have no idea how I did it but I'm still going to try to write what I did.
Save all and Close solution
Open the .vcxproj file (not .sln)
Build -> Clean [Project Name]
Save all and Close
Open the .sln file again.
Build -> Project Only -> Clean Only [Project Name]
Build -> Project Only -> Build Only [Project Name]
That's exactly what I did and worked for me. I think the main thing to do is clean, save, close, open, build, but I'm not sure.
In Solution Explorer you can select/deselect option "Show All Files".
Try both options and make sure excluded file is not included in project for both of them.
That's what I had:
I used "Show All Files" option (so you can see all the files in project directories). I excluded one of my .cpp files from project. However, it behaved as this file is in project.
That's how I managed to fix it:
I switched "Show All Files" off and saw this file still belongs to project! So I excluded this file once again.
As I see, that's a known issue.
This worked for me, hope it will be useful for someone else.
Try to verbose builder output to see exact steps of what's going on. I suppose, you use Visual Studio, right?
Go to menu "Tools -> Options"
In options dialog, select "Projects and Solutions -> Build and Run"
Change current mode of "MSBuild project build output verbosity" from "Minimal" to something like "Diagnostics" or "Detailed".
Rebuild your project and investigate Output windows
Builder dump should shed more light on your current settings (I suspect you have more references to that file than you expect)
This happened to me because I renamed folder from inside the IDE. None of the above solutions worked. The only way to fix this is by opening vcproj in notepad and you should see the offending files in the <ItemGroup>. Just delete those lines.
Or sometimes, like in my case, the issue is simply in the naming of the folders in the location. I had a very long path with folders that I like to name with special characters so they show up at the top and it's easy to access them.
As soon as I put my solution in a folder just in D: drive, the issue was gone.
When I renamed a file, I found I had to go to SolutionExplorer, Source File, select the file, first exclude from Project, then re-add it to project, and rebuild the solution it lives in. It was still showing up as the old file name under Source Files for me.
I had the same problem, but I had another .sln worked fine. After tooling around with the Project->Properties-> to make them look identical, nothing worked. I opened both .vcxproj files and copied the contents of the working version into my non-working version. (I noticed that the two files had different lengths. The non-working version was longer by about 20 lines.) I just changed the RootNameSpace to the non-working version's name. I saved the non-working file and presto! It worked.
I removed those sources from Project and re-added them. Somehow, references were messed up after a hurry project refactoring.
For people having problem related to "error C1083: Cannot open source file":
Error is caused by settings in *.vcxproj file. Probably you deleted/moved source file by file explorer, not by Visual Studio's "Solution Explorer". Thus, your *.vcxproj file is corrupted. Fix is to manually correct settings in *.vcxproj file.
How Visual Studio settings files work
Visual Studio saves solution's info into file. This file is usually in project's solution directory, has extension .sln and base name is same as name of solution, f.ex.:
NameOfSolution.sln
Similarly, project's info is saved into one file (each project has its own file). Base name of this file is name of project, extension is .vcxproj, and usually is located in subdirectory named as your project, f.ex.:
NameOf1stProject/NameOf1stProject.vcxproj
NameOf2ndProject/NameOf2ndProject.vcxproj
Both *.sln and *.vcxproj files are textual files. You can open them by using Notepad.
How to fix problem
Find *.vcxproj file responsible for your project.
If you don't know where it is, open in Notepad the *.sln file of your solution. Search for name of your solution. You will find line like:
Project("{9AA9CEB8-8B4A-11D0-8D22-00B0C01AA943}") = "NameOf1stProject", "NameOf1stProject\NameOf1stProject.vcxproj", "{A8735D0A-25ED-4285-AB8F-AF578D8DB960}"
Value under "NameOf1stProject\NameOf1stProject.vcxproj" is location of *.vcxproj file of your project.
Open found *.vcxproj file by text editor (f.ex. Notepad).
Search for line on which is filename you are struggling with.
Example: if you are looking for "RemovedFile.cpp", then you should find line:
<ClCompile Include="RemovedFile.cpp" />
Delete that line.
If you have opened Visual Studio, it asks you if it should refresh solution - select yes. If it is not opened - just start using it.
In case of any problems, try to rebuild solution (top banner -> Build -> Rebuild Solution)
In my cases, it worked. 30 mins of trying to fix, <1 minute of fixing.
This helped in my case. To sum it up, my path to the project was too long, so I moved my project to something shorter i.e. D:\my_project and everything worked in a blink of an eye.
I had this same problem, but for me the issues was that I was using Bash on Windows (WSL) to clone the repository and then using VS to compile.
Once I deleted my clone and used Windows command line (cmd.exe) to clone the repo then the error 1083 went away.
This is caused by not removing/deleting the file properly. Go to Solution Explorer, select your solution, at the left corner, activate the icon: show all files.
(if you already removed the problem file, restore it from recycle bin)
Select the problem file, do remove and delete from within Solution Explorer and you should not have this problem. And remember to do it the proper way from now on.
This is on MS 2010
If you have that file in your project directory but you still got the error, on your IDE go to Solution explorer--> Remove that file-->then open the project directory on your file explorer-->Select that file and drop it on a specific location in IDE solution explorer. I fixed it this way. I use the Windows platform.
I got this error when I got a code from my peer and I tried directly running it on my system. Ideally to avoid such errors, I should have just copied the source and header files and should have created the VS solution of my own.
To resolve the errors I removed the files from the Solution Explorer and added them again. Following image shows the Solution Explorer window.
The remove option comes after right clicking on the file names.