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
Make sure any XML file (or any file that would be interpreted as an XML file by visual studio) has a correct XML structure - that is, one root element (with any name, I have use rootElement
in my example):
<?xml version="1.0"?>
<rootElement>
...
</rootElement>
Deleting the .user file is exactly what fixed the problem for me. Lightning strike near the office shut my PC down and corrupted my .user file and project wouldn't load. I opened the file in Notepad++ and the "spaces" turned out to be [NULL] characters. Deleted the .user file and the file loaded!
source https://forums.asp.net/t/1491251.aspx?Can+t+load+project+because+root+element+is+missing+
In my case, I just renamed the .csproj.user and restart the visual studio and opened the project. It automatically created another .csproj.user file and the solution worked fine for me.
In my case, I got this error because of an empty packages.config
file.
This caused the NUGET package manager to fail and show the error Root element is missing.
The resolution was to copy over elements from another non-empty file and then change it according to the needs.
Example (packages.config):
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net451"/>
<package id="Newtonsoft.Json" version="5.0.4" targetFramework="net451"/>
</packages>
This error is caused by corrupted proj file.
Visual Studio always has backup project file at specific folder.
Please browse to:
C:\Users\<Your user>\Documents\Visual Studio <Vs version>\Backup Files\<your project>
You should see 2 files like this:
Original-May-18-2018-1209PM.<your project>.csproj
Recovered-May-18-2018-1209PM.<your project>.csproj
You only need copy file:
Original-May-18-2018-1209PM.<your project>.csproj
And re-name as
<your project>.csproj
and override at root project folder.
Problem is solved!
I got same error. showing error Microsoft.Data.Entity could not loaded root element missing. When i delete that file from C:\Windows\Microsoft.NET\Framework\v4.0.30319 and again open my solution my problem was solved. Everything woks fine