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

Building a DLL Project (DLL) in debug mode

Open Visual Studio 2005 IDE and create a Class Library project as mentioned below.

File >> New >> Project

·         Project types: Visual Basic

·         Visual Studio installed templates: Class Library

·         Project Name: DLLProject

Default class Class1.vb will be added in the project automatically. Rename it to CLibrary.vb.

Open CLibrary.vb in the code window and implement a function GetWelcomeMessage as given below:

Listing 1 – Implement function GetWelcomeMessage in CLibrary.vb 

''' <summary>
    ''' Get the welcome message on the basis of company name.
    ''' </summary>
    ''' <param name="Name">Name of Employee</param>
    ''' <param name="Company">Company of Employee</param>
    ''' <returns>Welcome Message</returns>
    ''' <remarks></remarks>
    Public Function GetWelcomeMessage(ByVal Name As String, 
      ByVal Company As StringAs String
 
        If Company = "mindfire" Then
            Return "Hello"
            Return "Hello " & Name & "! Thank you for viewing this article"
        Else
            Return "Hello Guest! Thank you for viewing this article"
        End If
 
    End Function

Save the project and build it by pressing Ctrl+Shift+B. If the build is successful then the sample DLLProject is ready. A DLLProject.dll file would have been created in …\DLLProject\bin\Debug folder. Now it is time to debug it. We can debug DLL projects in VS Studio 2005 in either of following two common ways.

I. Debug DLL project using Immediate Window.

II. Debug DLL project using external calling application.

A DLL programmer must know both ways of debugging. Why? You will know within a few moments. I am going to describe both ways in this article.


View Entire Article

User Comments

Title: Nice One   
Name: Marc
Date: 2011-06-23 7:27:27 AM
Comment:
Great article thanks so much! Nice and easy to understand
Title: FileNotFoundException error on debugging dll   
Name: Binkey
Date: 2011-02-08 4:55:58 PM
Comment:
When I do the above steps and press F5, I get an exception error "FileNotFoundException was unhandled box" stating "Could not load file or assembly 'AddDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
AddDll is the dll name. How could it not find the file. I'm running it?
Title: call dll from an exe question not answered   
Name: jeanie
Date: 2011-02-08 4:31:50 PM
Comment:
Nobody answered the question titled "call DLL from exe". How do you get the debugger to step into the dll when running the exe? Please advise if your still there.
Title: debug DLL   
Name: Robat7
Date: 2010-04-13 10:09:03 AM
Comment:
Thank you so much
Title: Saving DLL other than the Output Directory   
Name: Ali Asim
Date: 2010-03-19 1:40:37 PM
Comment:
\
\S
\
Title: call DLL from exe   
Name: Arun
Date: 2009-07-10 2:16:16 AM
Comment:
Hi, nice article. But I'm stuck at a point and think you'l be able to help me. I've created a dll class library project and attached it to a process. I've placed both .dll and .pdb files in the bin folder of the exe application. I've put the breakpoints in my dll project and now start the exe. The process runs and when the dll is called, the control does not enter the class created in the dll(I've put breakpoints at relevant positions). The process completes, but the control does not enter class library.
What I am doing wrong?
Any suggestions would be welcome. Thanks in advance.
Title: Re: Would it be same in 2005   
Name: Abhishek (Author)
Date: 2007-11-21 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: 2007-10-19 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: 2007-07-22 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: 2007-07-22 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: 2007-07-15 3:15:55 AM
Comment:
Hi Abishek

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

Product Spotlight
Product Spotlight 





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


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-19 2:20:11 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search