Josh Robinson's WebLog

December 2004 - Posts

How to debug and step through installer classes

I have finally figured out how to debug installer classes that are called by a custom action from a .NET deployment project.  You simply need to put the following line at the point in your code that you would like to begin debugging:

System.Diagnostics.Debugger.Break();

Run the installer and once it hits that line (I put mine in the overridden Install() method), it will ask you if you would like to open a new debugger.  Select Visual Studio, select the option to debug the Common Language Runtime (I deselected Native), hit Ok and now you will be able to step through your installer code, view local variables, etc.  Very easy and very useful when attempting to debug installer code.

Retrieving viewstate values from dyamically created server controls within a composite server control (SQL Reporting Services parameter control)

The problem that I am trying to solve is how to grab values of dynamically created controls from the viewstate if those dynamically created controls are in a composite server control.  To put the problem in context, the control in question is to display parameters from reports in reporting services.  I have it working pretty well on a page or user control, but would like to put it in a server control.  The basic steps I used when building this solution in a user control are as follows:

 

-----FIRST TIME LOADING PAGE-----

Page_Load()

{

            Call method to:

1.)    Connect to reporting services web service

2.)    Retrieve parameters for a given report

3.)    Loop through collection of returned parameters and render webcontrols to display them (textboxes, listboxes, etc.)

}

 

 

-----POSTBACK OCCURS-----

OnInit()

//Note: we have to call this in OnInit to build controls before Viewstate is reconstructed so that controls will be instantiated in order to match up with the ones built above which are contained in the Viewstate.

{

            Call same method as in Page_Load() above:

1.)    Connect to reporting services web service

2.)    Retrieve parameters for same report

3.)    Loop through collection of returned parameters and render webcontrols to display them (textboxes, listboxes, etc.)

}

 

Page_Load()

{

            Call method to:

1.)    Retrieve values of dynamic controls that were built in the OnInit() and are now matched up with the copy of the controls that were in the Viewstate.

 

Call method to:

1.)    Connect to reporting services web service

2.)    Retrieve parameters for a given report, passing in values captured from controls created in OnInit for purposes of cascading param updates, etc.

3.)    Loop through collection of returned parameters and update webcontrols to display new values.

}

 

This is relatively easy to do in a user control or aspx page, as I mentioned before, but I am trying to determine where in a composite server control would I perform these same actions since there is no “Page_Load” or “OnInit”?  Can I just override the CreateChildControls(), create the controls in there, and then on postback use CreateChildControls() to rebuild controls, retrieve values and update with new values from reporting services?  I have just started implementing the control, but those are some of the things that I am wondering.

 

The best reference I have found for maintaing viewstate in dynamic controls in a composite server control is on Scott Mitchell’s blog.

 

If anyone has any ideas, I would appreciate it.  I’ll try to post my findings here so that if anyone else runs into similar questions they’ll be able to see what I found.

More Posts