Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Web.UI.Control.LoadRecursive() called may times in my user control or page

I have a user control on one of my page and I am getting below error on this page

Object reference not set to an instance of an object.

I have resolved this issue very easily but I found something strange in the stack trace of this error.

When I checked stack trace this was like below

at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

It is not the complete stacktrace but a part of it. I want to know what is the role of this function "System.Web.UI.Control.LoadRecursive()". It is called 11 time and I am afraid that this may cause performance issue in my application. I think this function is called because I am using user control. I am using this kind of user controls at many places in my application.

Please tell me if any one knows about this.

like image 379
Nikhil Gaur Avatar asked Dec 05 '12 10:12

Nikhil Gaur


1 Answers

LoadRecursive() makes a call to the current control's OnLoad() method and then will recursively call LoadRecursive() on all of its child controls, including those nested in the html.

So you will have 1 LoadRecursive() call on the stack for every parent control that has been passed through to get to your custom control. Composite controls can have many in one which will add to the depth.

It is not necessarily a performance problem. Just an indication of nesting depth.

like image 69
Zoom Avatar answered Oct 20 '22 23:10

Zoom