今天遇到很奇怪的現象,我的Visual Studio 2008突然無法識別ASP.NET中的“asp”標籤首碼,開始以為是Visual Studio出問題了,重啟系統後還是沒有解決,然後在“添加和刪除程式”中修複了一遍Visual Studio,問題還是沒有解決。上Google一搜尋,有結果,在一個MSDN的部落格中看到:
I blogged earlier that in VS 2005 we switched from using static XML schemas to automatically generating them using reflection on Web controls. XML schemas are generated on demand as you open pages in your Web site. They contain information about ASP.NET controls, custom and user controls. You can find generated files cache in
C:\Documents and Settings\[Username]\Application Data\Microsoft\VisualStudio\8.0\ReflectedSchemas
So, the first thing you want to do if you see dreaded "'asp' is an unrecognized tag prefix or device filter" error is to close all VS instances and then delete the folder contents. Restart VS, open your Web site and we will generate schemas again.
然後我就把C:\Documents and Settings\[Username]\Application Data\Microsoft\VisualStudio\9.0刪掉(沒事,VS會重建的),再啟動VS開啟項目,一切正常了。
為什麼會出現此情況呢?那是因為我重新換了一個Windows使用者,然後把舊使用者裡的Application Data複製過來了,VS可能就不能識別ReflectedSchemas下面的內容,所以全部“asp”標籤首碼都無法識別了。