2009-06-24 101 views
11

我有一個包含多個項目的VS2008(C#)的解決方案。我剛剛爲我們的構建過程重新構建了一些.csproj文件,並且突然在編碼項目B時無法識別類代碼中的項目A的引用......認爲我創建的變量類型下的紅色波浪線。但是,構建解決方案不會產生錯誤。爲什麼它表現得像這樣?Visual Studio:代碼中的引用無法識別?

回答

19

我建議你清理你的Visual Studio臨時文件 - 它經常會對項目結構感到困惑,並且需要重新開始。

首先,完全退出VS並重新啓動它。如果問題仍然存在,找到您的VS緩存文件夾並將其刪除,然後重建。

如需查找您的緩存文件夾,請致電check this post

2

在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

1

確保這兩個項目正在建設中的配置管理器

(右鍵單擊解決方案,然後單擊「配置管理器」)

您也可以懸停在紅線或只是再次打造看看如果你有更多的細節。 C#和VB都很擅長告訴你他們爲什麼不開心。

3

當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 .. 
相關問題