如何修复“根元素丢失”。当进行 Visual Studio (VS) 构建时?
如何修复“根元素丢失”。当进行 Visual Studio (VS) 构建时?
知道我的解决方案中应该查看什么文件吗?
实际上,当使用“Make VS 2008”命令时,我在“Visual Build Pro”中收到此错误消息。这个命令在构建其他解决方案(例如大约 20 个)时工作得很好,我不太确定为什么我的解决方案会出现错误。
任何帮助将非常感激。 :)
我正在使用 VS 2008 和 Visual Build Pro 6.7。
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 this error message inside of "Visual Build Pro" when using using the "Make VS 2008" command. This command works just fine when building other solutions (like about 20) and I am not really sure why mine is getting the error.
Any help would be very much appreciated. :)
I am using VS 2008 and Visual Build Pro 6.7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
就我而言,问题是由于在 Visual Studio 保持打开状态时关闭我的电脑而发生的,因此结果 csproj.user 文件保存为空。值得庆幸的是我已经备份了,所以我只是从 csproj.user 复制了所有 xml 并粘贴到我受影响的项目 csproj.user 文件中,所以它工作得很好。
该文件仅包含构建设备信息等。
In my case the problem occurred due to closing my PC while visual studio were remain open, so in result csproj.user file saved empty. Thankfully i have already backup, so i just copied all xml from csproj.user and paste in my affected project csproj.user file ,so it worked perfectly.
This file just contain building device info and some more.
就我而言,是 xxxxxxxxxxxx.vcxproj.user 文件导致了问题;崩溃后它是空白的。我重命名了它,问题就消失了。
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.
确保任何 XML 文件(或任何将被 Visual Studio 解释为 XML 文件的文件)都具有正确的 XML 结构 - 即一个根元素(具有任何名称,我已在中使用
rootElement
我的例子):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):当 BOM 出现时,您还会收到“根元素丢失”的信息:)。 BOM = 字节顺序标记。这是一个额外的字符,当使用错误的编码保存时,该字符会添加到文件的开头。
在 Visual Studio 中处理 XML 文件时有时会发生这种情况。您可以编写一些代码将其从所有文件中删除,或者如果您知道它是哪个文件,则可以强制 Visual Studio 使用特定编码(utf-8 或 ascii IIRC)保存它。
如果您在 VS 以外的编辑器中打开该文件(尝试 notepad++),您将在
要在 VS 中修复此问题,请在 VS 中打开文件,然后根据 VS
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
就我而言,我收到指向
NuGet.Config
文件的缺少元素错误。当时它看起来像这样
,然后我只是添加了实际上包装整个 xml 的
configuration
标签。现在对我来说工作得很好In my case.I was getting missing element error pointing to
NuGet.Config
file.At that time it was looking some thing like this
then I just added
configuration
tag that actually wraps entire xml. Now working fine for me此错误是由损坏的 proj 文件引起的。
Visual Studio 始终在特定文件夹中具有备份项目文件。
请浏览至:
您应该看到像这样的 2 个文件:
您只需要复制文件:
重命名为
并在根项目文件夹中
并覆盖。问题解决了!
This error is caused by corrupted proj file.
Visual Studio always has backup project file at specific folder.
Please browse to:
You should see 2 files like this:
You only need copy file:
And re-name as
and override at root project folder.
Problem is solved!
我的项目未加载,并出现
Root Element Missing
错误。我刚刚删除了****.csproj.user
文件并再次重新加载。问题是这样解决的My project did not load and gave me a
Root Element Missing
error. I just deleted****.csproj.user
file and reloaded it again. The problem was solved this way就我而言,当我打开
.csproj
文件时,它是空的,因此我转到 git 中之前的提交,复制该文件的内容并将其粘贴到我当前的.csproj 文件。之后,我删除了 .csproj.user 文件,重新加载了我的项目,一切又开始工作了。
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.我在运行 VS 2017 时遇到了这个问题,在构建时我收到“根元素丢失”的错误。为我解决这个问题的是工具>; Nuget包管理器>包管理器设置>一般>清除所有 Nuget 缓存。完成此操作后,我再次运行构建并修复了问题。
I had this issue running VS 2017, on build I was getting the error that the 'root element was missing'. What solved it for me was going to Tools > Nuget Package Manager > Package Manager Settings > General > Clear all Nuget Caches. After doing that I ran the build again and it was fixed.
您还可以搜索该文件。使用 PowerShell 导航到您的项目目录并运行 Get-FileMissingRoot:
You can also search for the file. Navigate to your project directory with PowerShell and run Get-FileMissingRoot:
我遇到了同样的错误。显示错误 Microsoft.Data.Entity 无法加载根元素丢失。当我从 C:\Windows\Microsoft.NET\Framework\v4.0.30319 删除该文件并再次打开我的解决方案时,我的问题得到了解决。一切正常
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
就我而言,.csproj 已更改为编码格式。我在 Git(团队资源管理器)中撤消了对 csproj 的更改并重新加载了项目文件。这解决了问题。
In my case, .csproj was changed to encoded format. I did undo changes to csproj in Git(Team explorer) and reloaded the project file. This solved the problem.
就我而言,文件
C:\Users\xxx\AppData\Local\PreEmptive Solutions\Dotfuscator Professional Edition\4.0\dfusrprf.xml
充满了 NULL。我把它删除了;它在 Dotfuscator 第一次启动时被重新创建,之后恢复正常。
In my case, the file
C:\Users\xxx\AppData\Local\PreEmptive Solutions\Dotfuscator Professional Edition\4.0\dfusrprf.xml
was full of NULL.I deleted it; it was recreated on the first launch of Dotfuscator, and after that, normality was restored.
当您编辑 Atmel Studio 6.1.2730 SP2 的某些项目工具链设置时,有时会出现此错误。
就我而言,我尝试编辑项目属性>工具链>链接器>在配置中选择“所有配置”的常规设置。当我选中或取消选中某个设置时,会弹出一个包含错误的对话框。然而,我发现如果我一次只对一个构建配置进行相同的编辑,我就可以进行相同的编辑;即仅选择“调试”或“发布”而不是“所有配置”。
有趣的是,即使选择了“所有配置”,我后来也能够编辑相同的链接器设置。我不知道我的项目发生了什么变化使得这成为可能。
This error can sometimes occur when you edit some Project Toolchain settings Atmel Studio 6.1.2730 SP2.
In my case I tried to edit Project Properties > Toolchain > Linker > General settings with 'All Configurations' selected in the Configuration. When I checked or unchecked a setting, a dialog with the error popped up. However, I found that I could make the same edits if I made them to only one build configuration at a time; i.e. with only 'Debug' or 'Release' selected instead of 'All Configurations'.
Interestingly, I later was able to edit the same Linker settings even with 'All Configurations' selected. I don't know what changed in my project that made this possible.
我在运行 Visual Studio 2013 时遇到蓝屏,当我重新启动时,我打算再次运行我的项目,但我总是遇到这个 headius 错误。
无论如何
删除带有临时信息的文件夹修复此问题。
就我而言,该项目是 Windows 服务器,基本上它会创建一个包含一些 Tem 信息的文件夹。
该文件夹位于
存在一个带有项目名称的文件夹+一些生成的 GUI 中
Service.ServerHostLoader_Url_u2jn0xkgjf1th0a3i2v03ft15vj4x52i
这是我删除的文件夹,现在我可以再次运行该项目。
I had Blue Screen while running Visual Studio 2013, when I Restart I intended to run again my project, but I had always this headius Error.
anyway
Deleting The Folders with the Temp info Fix this problem.
in my case the Project was a Windows Server, and Basically it Creates a Folder with some Tem info.
the folder was
inside Exist a Folder with the Name of the Project+ some Generated GUI
Service.ServerHostLoader_Url_u2jn0xkgjf1th0a3i2v03ft15vj4x52i
this is the Folder I deleted and now I can run again the Project.
就我而言,我升级到 VS2017,并希望使用我的构建脚本(当我们使用 VS2015 时一直使用 MSBuild 3.5)使用 MSBuild 4 构建所有项目。 MSBuild 升级对于 Windows 桌面应用程序来说似乎很好,但对于具有紧凑框架的 Windows CE 来说,会给我带来这个令人困惑的错误。对于 Windows CE 项目恢复到 MSBuild 3.5 解决了我的问题。
顺便说一句,我确实在 .csproj 文件中包含了 BOM,并在无法构建但没有帮助的解决方案中删除了所有项目的 BOM。
In my case I upgraded to VS2017 and wanted to build all projects with MSBuild 4 with my build script (which had been using MSBuild 3.5 when we were using VS2015). That MSBuild upgrade appeared fine for the Windows desktop applications but the ones for Windows CE with compact framework would give me this confusing error. Reverting to MSBuild 3.5 for Windows CE projects fixed the issue for me.
I did have the BOM in .csproj files by the way and removed them for all projects in a solution that would not build but that did not help.
在 xamarin 形式项目中。我删除了
In xamarin form project. I deleted
就我而言,我收到了这样的消息:
查看这张图片
我刚刚在项目文件 (.csproj) 中评论了下面的片段代码和问题已解决。
In my case I received a message like this:
See this picture
I just commented the snipped code below in the project file (.csproj) and the problem was fixed.
就我而言,尝试发布应用程序时未加载 xxxx.pubxml.user。我删除了该文件并重新启动 Visual Studio,然后创建了一个新的配置文件来发布它,问题已解决并成功发布。
In my case xxxx.pubxml.user was not loaded when tried to publish the application. I deleted the file and restart the Visual studio then created a new profile to publish it, problem is solved and published successfully.
嘿,我在 Mac 上使用 Cocoa C# 解决方案时遇到了同样的问题。
(但我解决了!)
它总是说根元素丢失,因此无法加载我的 C# 项目文件。
我有 2017 Visual Studio Mac 社区版。
几个小时后我终于找到了解决方案(痛苦!)。
我的解决方案是因为与 Visual Studio 相关的框架太旧或损坏。
我发现这个是因为我尝试通过 Cocoa 创建一个新的 Mac 解决方案,但它说“无法保存解决方案”。然后,我尝试创建一个 Android 解决方案,它运行良好。
转到您的“Finder”并“Go”-> “转到文件夹”然后转到“库/框架”。我删除了 mono.framework 和与 Xamarin 相关的框架,因为我相信这些 Xamarin 框架已损坏。
然后,卸载 Visual Studio 并重新安装。
现在一切正常!
Hey, I have the same issue on Mac working on a Cocoa C# solution.
(But I solved it !)
It always say that the root element is missing so it cannot load my C# project file.
I have the 2017 Visual Studio Mac Community Edition.
I finally managed to find a solution after several hours (painful!).
My solution is because the frameworks related to the Visual Studio are old or broken.
I found this because I tried to create a new Mac solution by Cocoa and it said "failed to save the solution". Then, I tried to create an Android Solution and it is working fine.
Go to your "Finder" and "Go" -> "Go to a Folder" then go to the "Library/Frameworks". I have deleted mono.framework and frameworks related to Xamarin because I believe these Xamarin frameworks are broken.
Then, uninstalled the Visual Studio and reinstalled it.
Now everything works fine!
就我而言,我只是重命名 .csproj.user 并重新启动 Visual Studio 并打开该项目。它自动创建了另一个 .csproj.user 文件,该解决方案对我来说效果很好。
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.
就我而言,Microsoft.Common.CurrentVersion.targets已损坏。我从其他系统复制了这个文件并且它有效。
In my case Microsoft.Common.CurrentVersion.targets was corrupted. I copied this file from other system and it worked.
我只是通过转到源代码控制资源管理器并选择问题项目来解决这个问题,右键单击并选择“高级”菜单下的“获取特定版本”选项。然后选择“类型”为“最新版本”并勾选以下两个复选框,然后单击“获取”按钮。然后我刷新了解决方案,我的项目恢复正常,问题消失了。请注意,这可能会覆盖您的本地项目,因此您当前的更改可能会丢失。因此,如果您的本地副本没有任何问题,那么您可以尝试此操作。希望有帮助
Ho i simply solved this issue by going to source control explorer and selected the issue project, right clicked and selected the option Get Specific Version under Advanced menu. And then selected Type as Latest Version and ticked following two check boxes and clicked Get button. Then i refreshed the solution and my project came back to live and problem gone. Please note that This may overwrite your local projects so your current changes may lose. So if you dont have any issues with your local copy then you can try this. Hope it helps
我在 Web API 项目中遇到了这个问题。最后发现它在我的“///”方法注释中。我将这些注释设置为自动生成 API 方法的文档。我的评论中的某些内容让它变得疯狂。我删除了所有回车符、特殊字符等。不太确定它不喜欢哪一个,但它有效。
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.
就我而言,RDLC 文件与资源文件 (.resx) 一起使用,我遇到此错误是因为我没有为 rdlc 报告创建相应的 resx 文件。
我的解决方案是以这种方式将文件 .resx 添加到 App_LocalResources 中:
In my case the RDLC files work with resource files (.resx), I had this error because I hadn't created the correspondent resx file for my rdlc report.
My solution was add the file .resx inside the App_LocalResources in this way:
我遇到过几次大规模的 VS2015 社区崩溃。
删除所有充满空字符的
I had a few massive VS2015 Community crashes.
which were full of null characters, and also these
就我而言,由于空
packages.config
文件而出现此错误。这导致 NUGET 包管理器失败并显示错误根元素丢失。
解决方案是从另一个非空文件复制元素,然后根据需要进行更改。
示例(packages.config):
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):
就我而言,我使用的是 vs 2010 和水晶报告。内部异常显示根元素丢失错误。转到内部消息中给出的 C:\Users\sam\AppData\Local\dssms\dssms.vshost.exe_Url_uy5is55gioxym5avqidulehrfjbdsn13\1.0.0.0 等目录,并确保 user.config 是正确的 XML(由于某种原因我的为空)。
In my case, i was using vs 2010 with crystal report. Innerexception revealed root element is missing error. Go to directory like C:\Users\sam\AppData\Local\dssms\dssms.vshost.exe_Url_uy5is55gioxym5avqidulehrfjbdsn13\1.0.0.0 which is given in the innermessage and make sure user.config is proper XML (mine was blank for some reason).
删除 .user 文件正是解决我问题的方法。办公室附近的雷击关闭了我的电脑并损坏了我的 .user 文件,并且项目无法加载。我在 Notepad++ 中打开该文件,结果“空格”是 [NULL] 字符。删除了 .user 文件并加载了文件!
来源 https:// /forums.asp.net/t/1491251.aspx?可以+t+load+project+because+root+element+is+missing+
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+
我在 Xamarin Forms 项目中遇到了同样的问题。 iOS 项目不可用,我无法重新加载该项目。我一直在寻找一种不需要卸载任何东西的解决方案。
我从这个博客得到的答案:
https:// /dev.to/codeprototype/xamarin-form-application-failed-to-load-android-project-root-element-missing--27o0
因此,无需卸载任何内容,您就可以删除 .csproj.user 文件(或重命名),以便 Visual Studio 将再次创建该文件。为我工作过两次。
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.