Debugging a class library in a web application

Debugging a class library in a web application is pretty simple. But, this is something that can be tricky when you are joining a new organization or project.

If you do not know how to debug a class library in a web application, here are the steps:

  1. Enable debugging on the web application.
  2. Deploy a debug version of the class library with breakpoints.
  3. Attach Visual Studio (debugger) with the ASP.NET worker process.

Enable debugging on the web application

In web.config of the web application, make sure that the debug flag is set to true.

When you set the debug flag to true for a web application, we allow any debugger to attach to the web application.

Deploy the class library

Prepare a debug version of the class library with breakpoints. Deploy the class library in the IIS server where the web application is running.

In the project properties of the class library, go to the Build tab, and change the output path to the bin directory where the web application is installed.

debug

Attach to the ASP.NET process using Visual Studio

In Visual Studio, attach the default debugger to the w3wp process (ASP.NET process). When a breakpoint is hit, Visual Studio debugger shows the corresponding source code.

When you are joining a new organization, setting up debugging on your local system is probably the first task that you need to do. When you are debugging a class library, you need to know the entry points in the library where you need to put the breakpoints.

Leave a Reply

Your email address will not be published. Required fields are marked *