2012-03-19 88 views
0

我們最近升級了網站項目,Visual Studio 2010中升級到Visual Studio 2010後 - 類型或命名空間名稱xxxxxxxxx_ascx'不存在命名空間存在「ASP」

我現在得到這個錯誤,每當我嘗試使用「允許此預編譯的網站可更新」進行發佈。

這工作以前使用Visual Studio 2008,所以我不知道它爲什麼現在不工作。

The type or namespace name 'xxxxxxxxx_ascx' does not exist in the namespace 'ASP' 
(are you  missing an assembly reference?) 

導致錯誤的行都是這樣做的。

ASP.content_Controls_Info_ascx infoControl = new ASP.content_Controls_Info_ascx(); 
infoControl.Stages = query.ToList(); 
PlaceHolder1.Controls.Add(infoControl); 

所以點網框架仍然是3.5

該網站建立罰款,並發表作品沒有我還沒有升級別的「允許此預編譯站點可更新」檢查。代碼中的content_Controls_Info_ascx部分也突出顯示了類名,因此可以找到它。

回答

3

.sln文件找到與您的網站項目相關的部分。它看起來像這樣:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "YourWebProject", "..\WEB\YourWebProject", "{A3774FE1-AA19-4A0F-94C9-FA58084B2429}" 
    ProjectSection(WebsiteProperties) = preProject 
     TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0" 
     ProjectReferences = "..." 
     Debug.AspNetCompiler.VirtualPath = "/YourWebProject" 
     Debug.AspNetCompiler.PhysicalPath = "..\WEB\YourWebProject\" 
     Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\YourWebProject\" 
     Debug.AspNetCompiler.Updateable = "true" 
     Debug.AspNetCompiler.ForceOverwrite = "true" 
     Debug.AspNetCompiler.FixedNames = "false" 
     Debug.AspNetCompiler.Debug = "True" 
     Release.AspNetCompiler.VirtualPath = "/YourWebProject" 
     Release.AspNetCompiler.PhysicalPath = "..\WEB\YourWebProject\" 
     Release.AspNetCompiler.TargetPath = "PrecompiledWeb\YourWebProject\" 
     Release.AspNetCompiler.Updateable = "true" 
     Release.AspNetCompiler.ForceOverwrite = "true" 
     Release.AspNetCompiler.FixedNames = "false" 
     Release.AspNetCompiler.Debug = "False" 
     VWDPort = "2487" 
    EndProjectSection 
EndProject 

,並設置以下屬性爲 「」(我用記事本編輯.sln文件):

  • Debug.AspNetCompiler.Updateable = 「
  • Release.AspNetCompiler.Updateable = 「

默認情況下它們被設置爲在發生「真正」和錯誤:

類型或命名空間名稱xxxxxxxxx_ascx'不存在命名空間存在「ASP」 (是否缺少程序集引用? )

這個解決方案幫了我。

1

這是網站模板的已知問題。解決方案是轉換爲Web應用程序項目。更多信息:

http://codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx

http://www.west-wind.com/weblog/posts/2005/Sep/12/Understanding-Page-Inheritance-in-ASPNET-20

你可以檢查的情況下,這是發生了什麼事,但與該網站模板,你很可能會特別是用戶控制和外部項目/庫再次運行到這個問題您參考。

相關問題