Home > DeveloperSection > Blogs > Creating dll in c#.

Creating dll in c#.

C# C# 
1 Comment(s)
 5410  View(s)
Rate this:

In this blog I will tell you that how to create dll in c# by using notepad and visual studio command prompt. Here I will provide you a sample algorithm which is helpful for you while creating dll in c#.

1)      Create a class for which you want to create a dll. Like following example will be demonstrate a sample class.

                This is a program which give you a demonstration that how to

                make a dll in c# using notepad and visual studio command prompt.


using System;   //A basic namespace which is required for c# program.

public class Employee


                public void disp()


                                Console.WriteLine("This is sample dll created by notepad and c# compiler.");




2)      Save this class in a file by using valid filename. I had save this file by using Employee.cs for this demonstration.

3)      Now compile this file by using following syntax.

               csc  /target:library Employee.cs

               This will create a dll for Employee class. Here target:library will denotes that a dll should be      created after compilation.

4)      Now create another file in which create a TestEmployee named class which used this dll. Following example will demonstrate use of this class.


                This is a sample program which will execute



using System;

public class TestEmployee


                public static void Main()


                                Console.WriteLine("Testing of Employee.dll begins....");

                                Employee emp=new Employee();   //Create an object of Employee class.

                                emp.disp();                    //Call disp() method of Employee class.

                                Console.WriteLine("Testing of Employee.dll ends....");




5)      Save this file by using TestEmployee.cs .

6)      Compile this file by using following syntax.

               csc  /reference:Employee.dll  TestEmployee.cs

Here reference word tells that Employee.dll is added in program before compiling.

7)      Now execute program by writing TextEmployee.exe and see the output.


By Samuel Fernandes on   one month ago

It was really helpful to read this post on dll

Don't want to miss updates? Please click the below button!

Follow MindStick