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

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

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


当前回答

REM DELETE ALL VS HIDDEN SOLUTION OPTION FILES
DEL /A:H /S *.SUO

其他回答

我发现,如果被引用的项目的目标是框架的更高版本,而不是试图使用它的项目,就会发生这种情况。你可以通过进入输出窗口并寻找类似的内容来判断这是否是问题所在:

无法解析主引用“my_reference”,因为它 是基于“. net framework,Version=v4.7.2”框架构建的。这 是比当前目标框架更高的版本吗 “.NETFramework, Version = v4.7 "。

解决方案是更改一个或其他项目的目标框架。

重新安装Visual Studio

在浪费了几个小时后,我仍然无法修复Visual Studio 2017。然后我安装了Visual Studio 2019 PREVIEW,突然间,IntelliSense再次向我显示stl类的成员(这在Visual Studio 2017中没有)。

所以,我的猜测是Visual Studio本身可能也有问题(可能是缓存目录中的问题或在你的PC上的一般性问题,这与特定的解决方案没有直接关系),可以通过干净完整的重新安装Visual Studio来解决。我知道,这是一个愚蠢的“解决方案”,但在我的情况下,只有一个新的Visual Studio(2019)安装才有效果。

如前所述,在我的案例中,只有STL类受到影响。智能感知不会显示它们的成员,这很奇怪。我想,这可能与预编译头有关。我在某处读到,STL和项目应该在同一个驱动器上,把它们放在同一个驱动器上应该能解决问题。但这些路线都没有成功。

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

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

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.

我通过删除Microsoft . net框架的临时文件解决了这个问题。 地点: C:\Windows\ Microsoft.NET \ Framework64 \ v4.0.30319 \临时ASP。网络文件 而且 C:\Windows\ Microsoft.NET \ Framework \ v4.0.30319 \临时ASP。网络文件