Debugging DLL Projects in Visual Studio 2005
page 3 of 6
by Abhishek Kumar Singh
Feedback
Average Rating: 
Views (Total / Last 10 Days): 31000/ 388

Debug DLL project using Immediate Window

To debug the library functions using immediate window, we can follow any of the following ways:

·         By implementing procedure Main() which calls the library function.

·         By making the library function Shared.

Debug by implementing Main() in module to call the library function.

In the DLLProject press CTRL+Shift+A to open Add New Item window. Choose Module and let the name be Module1.vb. Add the code given in Listing 2 in the Module1.vb.

Listing 2 – Implement Main() in Module1.vb to call the library function

Module Module1
    Sub Main()
        Dim oCLibrary As New CLibrary
        oCLibrary.GetWelcomeMessage("MyName""MyCompany")
    End Sub
End Module

The Main() function is implemented to call the library function GetWelcomeMessage by passing required parameters. Now we can set breakpoint at any line in the definition of Main() or GetWelcomeMessage and use immediate windows to step into the code as we do in any other windows or console applications.

Say I put the breakpoint at function GetWelcomeMessage as given in the figure below.

Figure 1 – Setting breakpoint in the library function code

Now open the immediate window by pressing CTRL+ALT+I or using Debug >> Window >> Immediate. Write Main() or ? Main() in the window and press the Enter key. You will see that breakpoint is hit by the execution pointer and now you can debug the function.

Figure 2 – Executing Main() from immediate window to step into the library function code

Debug using Shared access-specifier to the library function.

You can directly debug the functions implemented in class library application just by using Shared access-specifier for the functions. In this way you do not need the module file containing Main() procedure. In the immediate window call the shared function by using the class name. For example, to call the function GetWelcomeMessage in the class CLibrary of the sample DLLProject, write CLibrary.GetWelcomeMessage("MyName","MyCompany") in the immediate window and press Enter. The execution pointer will hit the breakpoint and thereafter you can debug the function.

Figure 3 – Executing Shared function from immediate window to step into the library function code


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 3 and 5 and type the answer here:

User Comments

Title: Re: Would it be same in 2005   
Name: Abhishek (Author)
Date: 11/21/2007 2:16:32 AM
Comment:
you should find the DLL file in bin folder as follows:
project folder >> bin >> debug/realease >> dll file
if you missed to locate your project folder, try this:
(Be sure you have created a library project)
1. In the VS 2005 IDE, open solution explorer.
2. in the tree structure there should a "bin" node, exapand that node by clicking on +
3. then you should see Debug or Release, open +
4. now you can see you dll file in the list.
5. right click on the dll and click on properties and see the path of the dll in the properties, and collect the dll file then.

Hope it helps you. Thanks.
Title: Would it be same in 2005   
Name: Ram
Date: 10/19/2007 12:42:23 PM
Comment:
Hi, you have described very well; but will it be happen in VS 2005.I could not see any bin folder to see the DLL file once you build the application.Do we need to create manually bin folder
Title: Reason fo not keeping both projects in same solution   
Name: Abhishek Kumar Singh
Date: 7/22/2007 4:43:41 PM
Comment:
darren, thanx for your suggestion.. but intensionally i didn't keep both projects in same soluction. I wanted to show that each porjects could be at different location .. may be in same computer or different computer over LAN. Also in case of large projects client and server projects use to be developed separately by different developers/team.
Title: Add both projects to same solution   
Name: darren
Date: 7/22/2007 4:06:33 PM
Comment:
You missed the best solution.
Add both projects to the same solution. Set a ref in the EXE to the DLL project. Set startup project as the EXE.
Title: Great Article   
Name: Dhanabalan.R
Date: 7/15/2007 3:15:55 AM
Comment:
Hi Abishek

Nice and Useful articles for developers
Title: Nice article   
Name: Macho
Date: 7/12/2007 2:07:02 PM
Comment:
Very good article for DLL masters and real life programming.

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2009 ASPAlliance.com  |  Page Processed at 1/8/2009 8:43:42 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search