我有一个问题与Visual Studio的c#解决方案。它会显示完全随机的错误,但项目会构建。现在,我有33个有错误的文件,我可以在所有文件中看到红色的弯曲线。
我尝试清理/重新构建解决方案,关闭Visual Studio,甚至重新启动计算机。我可以修改.cs文件,并看到解决方案中的更改。
有人知道为什么会这样吗?
我有一个问题与Visual Studio的c#解决方案。它会显示完全随机的错误,但项目会构建。现在,我有33个有错误的文件,我可以在所有文件中看到红色的弯曲线。
我尝试清理/重新构建解决方案,关闭Visual Studio,甚至重新启动计算机。我可以修改.cs文件,并看到解决方案中的更改。
有人知道为什么会这样吗?
当前回答
卸载&重新加载项目修复了这个问题。
其他回答
我发现在Visual Studio 2017中使用Git时经常发生这种情况,在有依赖代码更改的地方切换分支。即使项目将成功构建,错误列表中仍然会有错误。
这些错误通常是名称空间问题和缺少引用,即使库引用存在。
解决:
关闭Visual Studio 删除{sln-root}.vs\SlnName\v15. txt文件。锁文件(隐藏) 重启Visual Studio
卸载&重新加载项目修复了这个问题。
我注意到,有时在切换git分支时,Visual Studio(2017)将无法识别在第二个分支中添加的某些文件的类型。删除.vs文件夹可以解决这个问题,但它也会破坏所有的工作空间设置。这个技巧似乎对我很管用:
解决方案资源管理器->找到其中包含未识别类的文件。 单击解决方案资源管理器顶部的“显示所有文件”。 右键单击文件-> Exclude from project。 再次右键单击文件-> Include in project。
这会导致智能感知在切换分支时解析它错过的文件。
在我的例子中,帮助了很多事情:
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.
REM DELETE ALL VS HIDDEN SOLUTION OPTION FILES
DEL /A:H /S *.SUO