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

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

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


当前回答

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

其他回答

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

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

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文件夹解决了这个问题。

但它也重置了我的解决方案在VS中的当前设置,就像,我在解决方案中卸载的项目被重新加载,当我重新启动VS时,所有固定和打开的文档也被关闭了。

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

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

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

我发现在Visual Studio 2017中使用Git时经常发生这种情况,在有依赖代码更改的地方切换分支。即使项目将成功构建,错误列表中仍然会有错误。

这些错误通常是名称空间问题和缺少引用,即使库引用存在。

解决:

关闭Visual Studio 删除{sln-root}.vs\SlnName\v15. txt文件。锁文件(隐藏) 重启Visual Studio