How to Create a DLL file in .NET Framework using Visual Studio

This article will show how to create a DLL file in .NET framework using Visual Studio.

Creating a dll file

To create a DLL follow the below steps

Open 'Visual Studio' and select File -> Open -> New ->Project


Click on OK Button. Once you click on Ok 'Button' your Class Library looks as


Now you can add whatever code that you need to. Here I have String as the return data type for the function. I will use this function in another project (.aspx) and show the Result in a TextBox.

namespace MyClassLibraryConsole
public class Class1
public string strfunction(string input)
string strmessage = input;
return strmessage;

Now you have to call this function in another project. Add New (or) Existing Project to your Solution. Here I am adding Existing .asp WebPages to my solution as follows.


Once you have added your New or Existing Project your Solution will looks as follows.


Adding created dll file in Solution Explorer:

Right click on DllDemo(.asp) solution and click on the select 'Add Reference'.


Now you can find dialog Box. Select 3rd tab 'Projects'. Now can find your created ClassLibrary (dll) as 'MyClassLibraryconsole'.Select it and click 'OK' button.


Now your dll is added successfully to your website. You can see your added dll in solution Explorer.


Calling dll file function in .aspx.cs page:

protected void Button1_Click(object sender, EventArgs e)
Class1 obj = new MyClassLibraryConsole.Class1();
  TextBox1.Text = obj.strfunction(
"Hellow World");

Showing the Result in TextBox:


Thanks for Reading my Article!