1

自 1.1 / 2003 升级到 .NET 4.0 / VS 2010 以来,设计模式在整个站点范围内都存在这个问题。

有很多可以用谷歌搜索的,我已经尝试过了。我错过了什么?

- 尝试从 Visual Studio 的另一个实例进行调试:错误创建控件 vs2010 MasterPage - 关于它应该如何工作的细节并不多。我启动了另一个 VS2010 的空实例并附加到 devenv.exe。设置调试-> 全部中断。在 VS 的网站实例中切换到设计模式。以调试模式运行 VS 的网站实例。什么都没发生。我希望这会有所帮助,因为我在页面中有一些用户控件。不过我找不到他们有什么问题。我能否获得有关如何准确进行此类调试的更多详细信息?有关 .aspx 源代码,请参见本文末尾。

- 注释掉页面标签中的一些 <% =Session["Username"]%> 垃圾,因为显然访问会话内容可能会导致这种情况

-检查了动态添加控件或访问未实例化对象的 OnInit() 方法。很干净:

#region Web Form Designer generated code
      override protected void OnInit(EventArgs e)
      {
          //
          // CODEGEN: This call is required by the ASP.NET Web Form Designer.
          //
          InitializeComponent();
          base.OnInit(e);
      }

      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {    
          this.cboURLFunction.SelectedIndexChanged += new System.EventHandler(this.cboURLFunction_SelectedIndexChanged_1);
          this.cboStandard.SelectedIndexChanged += new System.EventHandler(this.cboStandard_SelectedIndexChanged);
          this.cboType.SelectedIndexChanged += new System.EventHandler(this.cboType_SelectedIndexChanged);
          this.chkLegacy.CheckedChanged += new System.EventHandler(this.chkLegacy_CheckedChanged);
          this.btnRoute.Click += new System.EventHandler(this.btnRoute_Click);
          this.Load += new System.EventHandler(this.Page_Load);

      }
      #endregion

.aspx 页面源(精简):

<%@ Page language="c#" Codebehind="addRoute.aspx.cs" AutoEventWireup="false" Inherits="HTP.RHIO.WebPortal.addRoute" %>
<%@ Register TagPrefix="HeaderControl" TagName="ucHeader" Src="ucHeader.ascx" %>
<%@ Register TagPrefix="TopMenu" TagName="ucTopMenu" Src="ucTopMenu.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ucHelpLink" Src="ucHelpLink.ascx" %>
<HTML>
    <HEAD>
        <title>Add Route -
            <% =Session["Domain"]%>
            <% =Session["Username"]%>
        </title>
        <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
        <meta content="C#" name="CODE_LANGUAGE">
        <meta content="JavaScript" name="vs_defaultClientScript">
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
        <link href="./style/WebPortalMain.css" type="text/css" rel="stylesheet">
        <script type="text/javascript">
            function jvsValidate() {
    (removed for brevity)
            }               
        </script>
    </HEAD>
    <body leftmargin="5" topmargin="0" rightmargin="5">
        <form id="Form1" method="post" runat="server" onsubmit="return jvsValidate() ;">
            <table id="Table1" class="tableWidth" cellspacing="0" cellpadding="0" border="0">
                <!-- BEGIN HEADER ROW -->
                <tr>
                    <td class="headerSection" colspan="3"><HeaderControl:ucHeader id="UcHeader1" runat="server"></HeaderControl:ucHeader></td>
                </tr>
                <!-- END HEADER ROW -->
                <!-- BEGIN TOP NAV (IF NECCESSARY) -->
                <tr>
                    <td class="topNavSection" colspan="3">
                        <table cellspacing="0" cellpadding="0" width="100%" border="0">
                            <tr>
                                <td style="WIDTH: 857px"><TopMenu:ucTopMenu id="UcTopMenu1" runat="server" xmlfilename="./MenuFiles/menu.xml" xslfilename="./MenuFiles/menu.xsl"></TopMenu:ucTopMenu></td>
                                <td align="right" width="15%"><uc1:ucHelpLink id="UcHelpLink1" runat="server"></uc1:ucHelpLink></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <br>
            <table id="Table2" class="tableWidth" cellspacing="0" cellpadding="0" border="0">
                <tr>
                    <td colspan="3"><img src="graphics/servicers_routes.gif"></td>
                    <td align="right">
                        <asp:hyperlink id="backLink" runat="server">
                            <img src="./graphics/back.gif" border="0"></asp:hyperlink></td>
                </tr>

. . 等等 。

            </table>
            <!-- END MAIN BODY SECTION --></form>
    </body>
</HTML>
4

1 回答 1

0

你会在那里找到你的答案:http: //blogs.msdn.com/b/webdev/archive/2010/05/06/another-error-creating-control-in-the-design-view-with-object-reference -not-set-in-visual-studio-2010.aspx

于 2013-07-11T21:38:43.783 回答