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 String) As 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.