在 MonoDevelop 中,当我的解决方案构建和运行没有错误时,是什么导致“red-x”error-icon?

In MonoDevelop, what causes the “red-x” error-icon when my solution builds and runs without errors?

我在 MonoDevelop 中创建了一个小的 Hello World ASP.NET 项目。那些 red-x(红色对角十字)出现在我的解决方案中的大多数文件图标上,位于右下角。

该项目仍在编译和运行,没有明显的问题或导致问题的指示。我尝试将光标悬停在图标上,但没有出现工具提示。

这些图标是表示我的项目确实存在问题,还是只是随机出现?

这是问题解决方案的屏幕截图(左),以及用于比较的新解决方案(右):

红色错误覆盖图标来自版本控制。

如果您使用的是 Git,则红色图标表示与上次提交相比,该文件已被删除并重新创建。

重现此问题的一种方法是使用本地 git 存储库创建一个新的 C# 控制台项目。将新项目提交到 Git 本地,无需将其推送到远程存储库。然后使用 MonoDevelop 删除 Program.cs,然后在同一位置再次创建一个新的 Program.cs 文件。然后你应该看到一个红色图标,这意味着文件在 Git.

中被标记为已删除

如果您随后打开命令行并 运行 git status 您应该会看到如下内容:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    MyProject/Program.cs

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   MyProject/MyProject.csproj

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    MyProject/Program.cs