How to fix \"Root element is missing.\" when doing a Visual Studio (VS) Build?
Any idea what file I should look at in my solution?
Actually, I am getting thi
I had the same problem in a Xamarin Forms project. iOS project was unavailable and I couldn't reload the project. I was looking for a solution that doesn't need uninstalling anything.
The answer I got from this blog: https://dev.to/codeprototype/xamarin-form-application-failed-to-load-android-project-root-element-missing--27o0
So without uninstalling anything, you could delete the .csproj.user file (or rename it) so Visual Studio will create the file again. Worked for me twice.
You will also get 'root element is missing' when the BOM strikes :). BOM = byte order mark. This is an extra character that gets added to the start of a file when it is saved with the wrong encoding.
This can happen sometimes in Visual Studio when working with XML files. You can either code something to remove it from all your files, or if you know which file it is you can force visual studio to save it with a specific encoding (utf-8 or ascii IIRC).
If you open the file in an editor other than VS (try notepad++), you will see two funny characters before the <? xml declaration.
To fix this in VS, open the file in VS and then depending on the version of VS
I had a few massive VS2015 Community crashes.
Delete all the .csproj.user files
which were full of null characters, and also these
C:\Users\UserName\AppData\Local\Temp\
.NETFramework,Version=v4.0.AssemblyAttributes.cs .NETFramework,Version=v4.5.AssemblyAttributes.cs .NETFramework,Version=v4.5.2.AssemblyAttributes.cs
I got this issue on a Web API project. Finally figured out that it was in my "///" method comments. I have these comments set to auto-generate documentation for the API methods. Something in my comments made it go crazy. I deleted all the carriage returns, special characters, etc. Not really sure which thing it didn't like, but it worked.
In my case, when I opened the .csproj
file, it was empty so I went to my previous commit in git and copied the contents of that file and pasted it my current .csproj
file. After which I deleted the .csproj.user
file, reloaded my project, and everything started working again.
In my case it was the xxxxxxxxxxxx.vcxproj.user file that was causing the problem; it was blank after a crash. I renamed it and the problem went away.