title: VIsual Studio 2010 Design Mode Error Creating Control (Object reference not set)
body: <p>Design mode has this problem site-wide since upgrading to .NET 4.0 / VS 2010 from 1.1 / 2003.</p>
  
  <p>There's plenty to google on this and I've tried it all.  What am I missing?</p>
  
  <p>-Trying to debug from another instance of Visual Studio: <a href="https://stackoverflow.com/questions/3159427/error-creating-control-vs2010-masterpage">Error Creating Control vs2010 MasterPage</a> - there's not a whole lot of detail on how this is supposed to work.  I started another empty instance of VS2010 and attached to devenv.exe.  Set Debug->Break All.  Switched to design mode in the website instance of VS.  Ran the website instance of VS in debug mode.  Nothing happens.  I was hoping this could help because I <em>DO</em> have some user controls in the page.  I can't find anything wrong with them though.  Can I get more detail on how exactly to do this type of debugging?  See the end of this post for the .aspx source.</p>
  
  <p>-Commented out some &lt;% =Session["Username"]%> junk in the  tag of the page, since apparently accessing session stuff could cause this</p>
  
  <p>-Checked the OnInit() method for dynamically adding controls or accessing uninstantiated objects.  It's clean:</p>
  
  <pre><code>#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);
        }
  
        /// &lt;summary&gt;
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// &lt;/summary&gt;
        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
  </code></pre>
  
  <p>.Aspx page source (thinned):</p>
  
  <pre><code>&lt;%@ Page language="c#" Codebehind="addRoute.aspx.cs" AutoEventWireup="false" Inherits="HTP.RHIO.WebPortal.addRoute" %&gt;
  &lt;%@ Register TagPrefix="HeaderControl" TagName="ucHeader" Src="ucHeader.ascx" %&gt;
  &lt;%@ Register TagPrefix="TopMenu" TagName="ucTopMenu" Src="ucTopMenu.ascx" %&gt;
  &lt;%@ Register TagPrefix="uc1" TagName="ucHelpLink" Src="ucHelpLink.ascx" %&gt;
  &lt;HTML&gt;
      &lt;HEAD&gt;
          &lt;title&gt;Add Route -
              &lt;% =Session["Domain"]%&gt;
              &lt;% =Session["Username"]%&gt;
          &lt;/title&gt;
          &lt;meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"&gt;
          &lt;meta content="C#" name="CODE_LANGUAGE"&gt;
          &lt;meta content="JavaScript" name="vs_defaultClientScript"&gt;
          &lt;meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"&gt;
          &lt;link href="./style/WebPortalMain.css" type="text/css" rel="stylesheet"&gt;
          &lt;script type="text/javascript"&gt;
              function jvsValidate() {
      (removed for brevity)
              }               
          &lt;/script&gt;
      &lt;/HEAD&gt;
      &lt;body leftmargin="5" topmargin="0" rightmargin="5"&gt;
          &lt;form id="Form1" method="post" runat="server" onsubmit="return jvsValidate() ;"&gt;
              &lt;table id="Table1" class="tableWidth" cellspacing="0" cellpadding="0" border="0"&gt;
                  &lt;!-- BEGIN HEADER ROW --&gt;
                  &lt;tr&gt;
                      &lt;td class="headerSection" colspan="3"&gt;&lt;HeaderControl:ucHeader id="UcHeader1" runat="server"&gt;&lt;/HeaderControl:ucHeader&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;!-- END HEADER ROW --&gt;
                  &lt;!-- BEGIN TOP NAV (IF NECCESSARY) --&gt;
                  &lt;tr&gt;
                      &lt;td class="topNavSection" colspan="3"&gt;
                          &lt;table cellspacing="0" cellpadding="0" width="100%" border="0"&gt;
                              &lt;tr&gt;
                                  &lt;td style="WIDTH: 857px"&gt;&lt;TopMenu:ucTopMenu id="UcTopMenu1" runat="server" xmlfilename="./MenuFiles/menu.xml" xslfilename="./MenuFiles/menu.xsl"&gt;&lt;/TopMenu:ucTopMenu&gt;&lt;/td&gt;
                                  &lt;td align="right" width="15%"&gt;&lt;uc1:ucHelpLink id="UcHelpLink1" runat="server"&gt;&lt;/uc1:ucHelpLink&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;br&gt;
              &lt;table id="Table2" class="tableWidth" cellspacing="0" cellpadding="0" border="0"&gt;
                  &lt;tr&gt;
                      &lt;td colspan="3"&gt;&lt;img src="graphics/servicers_routes.gif"&gt;&lt;/td&gt;
                      &lt;td align="right"&gt;
                          &lt;asp:hyperlink id="backLink" runat="server"&gt;
                              &lt;img src="./graphics/back.gif" border="0"&gt;&lt;/asp:hyperlink&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  </code></pre>
  
  <p>.
  .
  etc
  .</p>
  
  <pre><code>            &lt;/table&gt;
              &lt;!-- END MAIN BODY SECTION --&gt;&lt;/form&gt;
      &lt;/body&gt;
  &lt;/HTML&gt;
  </code></pre>