我有一个问题与Visual Studio的c#解决方案。它会显示完全随机的错误,但项目会构建。现在,我有33个有错误的文件,我可以在所有文件中看到红色的弯曲线。

我尝试清理/重新构建解决方案,关闭Visual Studio,甚至重新启动计算机。我可以修改.cs文件,并看到解决方案中的更改。

有人知道为什么会这样吗?


当前回答

有很多删除SUO /隐藏解决方案文件的答案。

就我而言,这是因为我需要以管理员身份运行Visual Studio才能发布。会用管理权限覆盖那些文件。现在,当作为标准用户运行时,我无法摆脱任何错误。

如果我重新运行在管理模式,我能够解决所有的错误。

其他回答

我刚刚遇到这个问题后,恢复了一个git提交,添加文件回到我的项目。

清理和重建项目没有起作用,即使我在每一步之间关闭VS。

最终起作用的方法是将文件重命名为其他文件,然后再将其更改回来。facepalm指:

对于VS-2017,删除。vs文件夹对我来说很有效。

在我的例子中,帮助了很多事情:

deleting all old not needed files which were previously excluded from the project closing VS deleting all the bin folder contents deleting .vs folder Clean/Rebuild after that I still had some spurious errors, however the amount was significantly lower (from 200 to around 8) and the errors referred only to a resource dictionary path in Generic.xaml e.g. <ResourceDicitonary Source="example/path/somefile.xaml"> when I played around with the path trying to change it to a wrong one re-building then correcting it and rebuilding again, then this finally cleared all errors. It was specifically WPF project if that's relevant.

有很多删除SUO /隐藏解决方案文件的答案。

就我而言,这是因为我需要以管理员身份运行Visual Studio才能发布。会用管理权限覆盖那些文件。现在,当作为标准用户运行时,我无法摆脱任何错误。

如果我重新运行在管理模式,我能够解决所有的错误。

偶尔,我不得不做一个自定义清理,通过检查所有的项目,手动删除“bin”和“obj”文件夹。要在Visual Studio中看到它们,您必须为每个项目启用隐藏文件和文件夹。完成此操作后,重新构建解决方案。