Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Creating Control - Custom Control

I have a custom control and it works fine...except that the control cannot be rendered on Design Time. ( I am using VS 2008)

I am thinking many people who develop custom controls encounter this problem...The error I get is "Error Creating Control - CustomControlName" Object reference not set to an instance of an object.

I want a work around. or at least debug this...(Since this is a design time issue how to debug?)

I have tried if( !DesignMode) code on OnInit, OnPreRender, RenderContents, CreateChildControls Methods ( I am just shooting in the dark)...

Help pls. I really hope this is not a VS bug!


1 Answers

BFree's comment is the most likely issue, for a control to display in the design view it needs a parameterless constructor as the design viewer doesn't know how you would normally instantiate the control.

If you do have a parameterless constructor, can you paste some code in to show what's happening?

like image 193
Glenn Slaven Avatar answered Feb 14 '26 22:02

Glenn Slaven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!