• Search form is empty!

  • “Error Creating Control” at Design Time

    “Error Creating Control” at Design Time

    This looks like a problem Microsoft might fix in VS2010 SP1.

    The problem is the designer is trying to access code that might not be available at design time like Session state.

    Here is an example of what might cause such a problem:

    protected override void OnInit(EventArgs e)
    {
         base.OnInit(e);
         this.wucGrade1.Cancel += new EventHandler(wucGrade_Cancel);
         this.wucGrade1.Ok += new EventHandler(wucGrade_Ok);
    }


    The solution is to check for the availability of Context and Context.Session before code is executed. 

    The designer will pass over the following code and your controls will render.

    protected override void OnInit(EventArgs e)
    {
         base.OnInit(e);
         if (Context != null && Context.Session != null)
         {

             this.wucGrade1.Cancel += new EventHandler(wucGrade_Cancel);
             this.wucGrade1.Ok += new EventHandler(wucGrade_Ok);
         }
    }


    I found this at: