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

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

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


当前回答

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

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.

其他回答

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

尝试将鼠标悬停在带下划线的元素上。它通常会告诉你问题所在。要查看所有错误/警告的列表,请转到View => Error list。应该在IDE底部打开一个表,列出所有错误/警告。

也许你试图重置你的智能感知缓存。在visual studio 2012中,当我在一个有许多部分类定义的大型项目中工作时,我也遇到过类似的问题。 减少局部值部分地解决了问题,同时也清除了智能感知缓存。

我已经在这个问题上挣扎了一年多,但这些解决方案都帮不了我:

删除.suo 删除。vs文件夹 删除所有缓存/临时文件夹 删除obj / bin文件夹 卸载/重新加载项目

我终于修复了这个问题-我在记事本中打开vbproj/csproj文件,并注意到在ItemGroup部分中,有一个指向我的主项目dll的引用。我删除了这个参考,重新打开了我的解决方案,问题就解决了。

我清洗了溶液,关闭VS,重新打开,构建溶液,未解析的红色线被清洗,构建成功。