debug control


Here are the steps to debug a custom control in ASP.NET:

Lets assume we’ve coded our custom control in its own solution of type Class Library and that we have a clean compile.

Let’s assume we created a web application and that we would like to use our custom control in a web page.  Also let’s suppose we have already added all the necessary elements to plug our custom control into our web page.

1) Using Visual Studio, open your Class Library solution housing your custom control.  Click on the Build menu and select Configuration Manager.  Make sure the solution configuration is set to Debug. 

2) Open the source code of your custom control, set your debug breaks and build the solution.

3) Using Windows explorer, open the bin/debug folder of your custom control and copy your control’s dll and pdb files (check the time and date to ensure they are the ones you just compiled).

4) Using Windows explorer, open your web application bin folder and paste your custom control’s dll and pdb files you just copied.

5) Using Visual Studio, open your web application solution.  In Solution Explorer, right-click the references folder and add a reference to the dll fo the control from your web application’s bin directory.

6) Still in your web application, click on the Build menu and select Configuration Manager.  Make sure the solution configuration is set to Debug. 

7) Still in your web application, open your web page’s code behind and set a break in your page load event.  Start debugging and hit F11 until you step out of the load event at which point you will land in your custom control’s code. 

The very first time, you have to start stepping in the client web page in order to get into your control.  If you just hit GO, it will not break in your custom control code. 

Once you have stepped into your custom control’s code you can add more breaks at that point.  From now on, you can just hit GO and it will break in your control’s break points.

No comments:

Post a Comment