Visual Studio:代码中的引用无法识别?

Chr*_*ris 11 visual-studio

我在VS2008(C#)中有一个包含多个项目的解决方案.我刚刚为我们的构建过程重新编写了一些.csproj文件,并且突然编码项目B时不会识别类代码中项目A的引用...想想我创建的变量类型下的红色波浪线.但是,构建解决方案不会产生任何错误.为什么它会像这样?

wom*_*omp 23

我建议您清除Visual Studio临时文件 - 它经常会对项目结构感到困惑,需要重新开始.

首先,完全退出VS并重新启动它.如果问题仍然存在,请找到您的VS缓存文件夹并将其删除,然后进行重建.

有关查找缓存文件夹的帮助,请查看此帖子.

  • 重启+清理+重建就做到了.奇怪的行为,希望我知道为什么它首先这样做,所以我可以试着避免它,因为它发生在我身上几次.谢谢! (3认同)

Rea*_*eap 7

另一种解决方案


如果有关清除Visual Studio 缓存.NET 缓存和确保引用有效的其他答案不起作用,请尝试这个。

根据来源,并尝试这个解决方案,我取得了成功。删除 Visual Studio 解决方案缓存文件夹

  1. 关闭 Visual Studio 的所有实例
  2. 找到.vs解决方案中的隐藏文件夹。
  3. 删除整个隐藏.vs文件夹。
  4. 重建解决方案

-来源


Yoo*_*eek 6

当 VS 开始表现得很奇怪并且我找不到逻辑修复时,我会杀死 Visual Studio,并通过删除所有 bin/obj 文件夹手动执行“清理”。

我有一个批处理文件,它比我手动完成的速度更快。我把它放在我的解决方案目录中,我所有的项目都在子目录中。

rem "%%~dpa" says: Give me the (d)drive and (p)path of the (a, %%a) file.
rem However, our dir /a:d will result in only listing folders...
rem The final "%%a" is just appending the 'file' (diretory name) to the 
rem drive-and-path string
for /f %%a in ('dir /b /a:d *.*') do call :process "%%~dpa%%a"
pause
goto :eof

:process
echo Looking in %1
cd "%1"
if EXIST "%1\bin" (
   echo    Found 'bin' - it's gone now.
   rd /s /q "%1\bin"
)
if EXIST "%1\obj" (
   echo    Found 'obj' - it's gone now.
   rd /s /q "%1\obj"
)
cd ..
Run Code Online (Sandbox Code Playgroud)