Wednesday, December 15, 2010

Debugging a Dll

If you want to debug a dll, it should be called by an application, usually an .exe.
There are couple of ways to debug a Dll based upon the type and properties of the DLL.
Some ways are as follows:
1.) An application built in another project in the same Visual Studio solution that contains the class library.

2.) An existing application already deployed on a test or production computer.

3.) Located on the Web and accessed through a URL.

4.) A Web application that contains a Web page which embeds the DLL.

To debug a DLL, start by debugging the calling application, typically either an EXE or a Web application. There are several ways to debug it.

If you have a project for the calling application, you can open that project and start execution from the Debug menu

If the calling application is an existing program already deployed on a test or production computer and is already running you can attach to it. Use this method if the DLL is a control hosted by Internet Explorer, or a control on a Web page.

You can debug it from the Visual Studio Immediate window. In this case, the Immediate window plays the role of the application.

To specify an executable for the debug session

1.In Solution Explorer, select the project that creates the DLL.

2.From the View menu, choose Property Pages.

3.In the Property Pages dialog box, open the Configuration Properties folder and select the Debugging category.

4.In the Command box, specify the path name for the container. For example, C:\Program Files\MyApplication\MYAPP.EXE.

5.In the Command Arguments box, specify any necessary arguments for the executable.


Before you start debugging the calling application, you will usually want to set a breakpoint in the class library. When the breakpoint is hit, you can step through the code, observing the action at each line, until you isolate the problem.



No comments: