【问题标题】:After upgrading to Visual Studio 2010 - The type or namespace name 'xxxxxxxxx_ascx' does not exist in the namespace 'ASP'升级到 Visual Studio 2010 后 - 命名空间“ASP”中不存在类型或命名空间名称“xxxxxxxxx_ascx”
【发布时间】:2012-03-19 17:40:34
【问题描述】:

我们最近将网站项目升级到 Visual Studio 2010。

现在,每当我尝试发布网站并选中“允许此预编译的网站可更新”时,我都会收到此错误。

这之前使用 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 部分也突出显示了类名,以便找到它。

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    .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
    

    并将以下属性设置为“false”(我使用记事本编辑 .sln 文件):

    • Debug.AspNetCompiler.Updateable = "false"
    • Release.AspNetCompiler.Updateable = "false"

    默认情况下,它们被设置为“true”并发生错误:

    命名空间“ASP”中不存在类型或命名空间名称“xxxxxxxxx_ascx” (您是否缺少程序集参考?)

    这个解决方案帮助了我。

    【讨论】:

      【解决方案2】:

      这是网站模板的一个已知问题。解决方案是转换为 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

      您可以检查您的参考资料以防发生这种情况,但使用网站模板可能会再次遇到此问题,尤其是使用用户控件和外部项目/库时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-19
        • 1970-01-01
        • 2012-05-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多