Debugging a Class Library used in a Web Application

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I have two projects in the same Solution, one of which is a Web Application,
the other of which is a Class Library. When debugging, if I put a breakpoint
in the Web Application, it stops there when it should, but the debugger
refuses to stop at the breakpoints in the Class Library. Is there something
special I need to do when debugging a Class Library while using it in a Web
Application? Thanks.
 
Nathan Sokalski said:
I have two projects in the same Solution, one of which is a Web
Application, the other of which is a Class Library. When debugging, if I
put a breakpoint in the Web Application, it stops there when it should, but
the debugger refuses to stop at the breakpoints in the Class Library. Is
there something special I need to do when debugging a Class Library while
using it in a Web Application? Thanks.

Yes, place another breakpoint in the Class Library code at whatever the
entry points are.

-Scott
 
What would the entry point be? The specific class in the Class Library that
I am trying to debug inherits from System.Web.UI.WebControls.Image, and my
breakpoint is in an override of the Render method. I would think the entry
point would be the tag in the *.aspx file, but that obviously isn't right,
since breakpoints aren't allowed in *.aspx files. Where do I need to put the
additional breakpoint? Thanks.
 
Nathan said:
I have two projects in the same Solution, one of which is a Web
Application, the other of which is a Class Library. When debugging, if I
put a breakpoint in the Web Application, it stops there when it should,
but the debugger refuses to stop at the breakpoints in the Class
Library. Is there something special I need to do when debugging a Class
Library while using it in a Web Application? Thanks.

You can break at the line in the codebehind file that calls the methods
in the classlib project. You single step into the project's method and
from there it should stop at a breakpoint that has been set.
 
The Class Library is a library of controls, so there is no line in the
codebehind that calls it, because it is called from the *.aspx file as
controls.
 
If your webpage code-behind is making an instance of a class then the entry
point would be the constructor of the class in the class library project.

-Scott
 
I'm a little confused as to were to put everything. Is there an example
available anywhere that I can look at? Thanks.
 
Nathan Sokalski said:
I'm a little confused as to were to put everything. Is there an example
available anywhere that I can look at? Thanks.

1. You've got two projects; a web UI and a class library project.
2. You set a breakpoint in the code-behind of a file in the web UI project
where you would like to start debugging.
3. You set a breakpoint in the code of the class in the class library
project that will be called by your web UI project.

If your web UI project is making an instance of a class in your class
library project, just set a breakpoint on that class's constructor.

That's all there is to it.

-Scott
 
Nathan Sokalski said:
The Class Library is a library of controls, so there is no line in the
codebehind that calls it, because it is called from the *.aspx file as
controls.

Inside your library you have classes which inherit from controls.
Stick a break point in the constructor of the relevent class.
 
Back
Top