Search code examples
c++visual-studio-2015visual-studio-2017projects-and-solutions

WIN32 Application Solution Error: The Project File Could Not be Loaded. Root Element is Missing


I was going to program a game of Snake using SFML, and after downloading SFML, I tried to create a WIN32 Windows Application, and when I clicked finish in the Wizard, I got the following error:

Unable to read the project file "SFML-Snake2.vcxproj". C:\Users\arnav_1n7er7u\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props(0,0): The project file could not be loaded. Root element is missing.

This can be seen in the following screenshot, although it may be unclear: Error Image

So to try and solve this problem, I went to the appropriate directory and opened the file Microsoft.Cpp.Win32.user.props in Notepad. After doing so, I found something unusual: The file was full of whitespace, and the exact whitespace content was as follows:

 Whitespace                                                                                                                                                                                                                                                                                                                         

(The word whitespace wasn't written there, I just wrote it for the formatting).

In fact, there were two other files in this directory, and when I looked at them, they were also full of whitespace. I have a feeling that is the problem since it is unlikely Microsoft switched to the Whitespace Programming Language, but I have absolutely no idea what is supposed to be in the file. Could I be pointed in the right direction, to see what the problem is, and how to fix the Visual Studio error message so I can create my project?

UPDATE

Ok, to try and fix the problem, I uninstalled Visual Studio 2015, and instead now downloaded the new Visual Studio 2017. In this, I tried to create another WIN32 Windows Application, and got the exact same error, which can be seen as follows:

error in screenshot

This time, I tried to open the file Microsoft.Cpp.Win32.user.props and now found this content (For some reason I cannot copy and paste it): enter image description here

Now I am really confused. For some reason, now I cannot create WIN32 Applications in Visual Studio, whether it is 2015, or 2017. What should I do?


Solution

  • Yes! I figured out how to solve the problem. After reading this MSDN link, I followed the accepted answers idea to delete the files in the directory v4.0. After doing so, I created a new project, and Visual Studio was able to do so because it generated new files in place of the corrupted ones.