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

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

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


当前回答

0 -右键单击解决方案和清洁解决方案

1 -关闭VS

2 -删除项目的.suo文件

3 -开VS

4 -构建解决方案

其他回答

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

我遇到过这样的问题,智能感知似乎不能识别一个项目的存在(很多“找不到这种类型”,“这个名称空间不存在”等错误)。

在所有引用项目中删除并重新添加项目引用可以解决问题,但是可以通过编辑问题项目的.proj文件来修复潜在的原因。

在“缺失的”project' .csproj文件的顶部附近有一个元素:

<ProjectGuid>{GUID}</ProjectGuid>

在所有引用项目中。csproj文件都是项目引用:

<ProjectReference Include="..\OffendingProject\OffendingProject.csproj">
  <Project>{ANOTHER-GUID}</Project>
  <Name>Offending Project</Name>
</ProjectReference>

引用的GUID与项目的GUID不匹配。用{ANOTHER-GUID}替换上面的{GUID}解决了这个问题,而不必经过每个引用项目。

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

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.

下面的解决方案对我很有效

1 -关闭VS

2 -删除。vs文件夹

3 -开VS

4 -构建解决方案

很多事情都可能导致它,这里有一长串答案。以下是我解决这个问题的方法,在尝试了几乎所有其他方法之后。

在DEBUG模式下构建解决方案。然后在发布模式下构建它(当它有红色波浪线时,它不应该构建,但在我的情况下,它只是警告,应该有绿色波浪线,但它陷入混乱,给他们红色波浪线,即使在发布模式下,它还是构建了)。然后在DEBUG模式中构建。朝手上吐口水,转身三次可选。

对我来说很有用,其他都没用。