ARTICLE

Using DLL files in Visual Studio 2005 using C#

Posted by Chitkaran Singh Articles | Visual C# November 14, 2007
This article explains the procedure of creating DLL files using visual studio 2005. It is very quick and easy to learn.
Reader Level:

Part 1: Creating a Class Library (DLL)

In this section, we will learn how to create a simple DLL file

1. Open a New Project as shows below and Select Class Library from the templates.

@1.gif

Select the File Name and the Location where you want to save this file.

2. This is what you will see on the main window.

@2.gif

Now create a simple function in the class Class1.

In this case I have created the highlighted function to add two numbers.

3. Now, select Build Solution from the Build Menu in the Menu Bar.

3.gif 

4. Here is the DLL file created in the Debug folder.

4.gif

Now this DLL file can be copied and pasted anywhere and can be used by any number of programs at a given point of time. 

Part 2: Using a Class Library (DLL)

In this section, we will learn how to use the DLL file that we have created.

NOTE:

Namespace we used : MyDLL

Class                            : Class1

Function                      :  addnumbers(int a. int b) 

1. Create a new Windows Application. 
5.gif

2. Build a Simple Windows Form as Shown Below.

first-6.gif
3. Now, we need to add the Reference of the DLL file that we had created earlier.

6.gif 

4. Select the DLL file from the browse tab.

7.gif 

5. Now, we will use the class and the namespace of the DLL file.

Click on the button to generate an EventHandler

8.gif

Make a Note of the namespace that has been added to the coding. 

6. Create a new object of the class. Now add the member function of the class with the help of the Object c.

9.gif

7. This is how the event handler will look like.

first10.gif

8. Now, run the program.
And, here is the output.

10.gif 

This is just a simple dll file created. We can create DLL file for any method and use it anywhere we like.

Login to add your contents and source code to this article
post comment
     

All the references of my DLL are visible in my output directory. What is I want them to be in System directory!?

 

I have a DLL naming dev_Info.DLL and by putting its reference the project always puts them in my output directory. I don’t want my clients to find it in the output directory. So what should I do?

 

Posted by Ali Asim Mar 19, 2010

Very nice article

Posted by subash selvan Mar 18, 2010

very nice article.

..I wanted to register by paying if you guys have any remote desktop type of  helping .Net consultants in any problems 24/7 any time. please have that type of online helping service..which would be very helpful to all learners...n working consultants...


thanks

Posted by sachit poudel Nov 27, 2009

Its really nice

Posted by KS Karthikeyan Nov 17, 2009

Why using DLL file...What is Difference between Class file and DLL file...?

Posted by sathish kumar Sep 16, 2009
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.