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

问题描述:

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

我建议你清理你的Visual Studio临时文件 - 它经常会对项目结构感到困惑,并且需要重新开始。

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

如需查找您的缓存文件夹,请致电check this post

在B的项目属性中,确保项目A在依赖项下被选中。

+0

他们被检查。 – Chris 2009-06-24 15:34:38

+0

哦,好的。这值得一试。 – rlbond 2009-06-24 15:35:46

+0

是的,至少+1拍摄:)谢谢。 – Chris 2009-06-24 15:36:59

确保这两个项目正在建设中的配置管理器

(右键单击解决方案,然后单击“配置管理器”)

您也可以悬停在红线或只是再次打造看看如果你有更多的细节。 C#和VB都很擅长告诉你他们为什么不开心。

当VS开始行为奇怪的时候,我无法找到一个逻辑修复,我杀了Visual Studio,并通过删除所有bin/obj文件夹来手动执行'clean'。

我有一个批处理文件,这比我手动执行此操作更快。我把它放在我的解决方案目录中,我的所有项目都在子目录中。

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 ..