How can Create DLL File and Use it in .NET Application

By
If there is some reusable code ,which has to be used in more than one application,instead of specify the same code again and again,we can make a DLL File. DLL can not be execute independently.
There are some steps to make a .dll file and use it in .Net Application.Please follow steps one by one which are given below.
Step1:- First open your visual studio->go File->New Project->Select class Library->Click OK.
see it:-

Step2:- First open solution Explorer->Right click on  dll exampe->Add Reference->click on .NET->Select System.Windows.Forms->click OK.



Step3:- Write the following code which are given below:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace dllexample
{
    public class Class1
    {
        public void sum(int i, int ii)
        {
            int res = i + ii;

            MessageBox.Show(res.ToString());
        }

        public void multi(int i, int ii)
        {
            int res = i *ii;
            MessageBox.Show(res.ToString());
        }

    }
}
Step:4- Compile the program (Press F6).

Step5:- Now again open New Project->Select WindowsFormsApplication-> Click OK->Make the design which is as shown below:-

Step6:- Open Solution Explorer->Right click on solution Explorer->Click Add Reference->select Browse->Go dllexample File->Bin->Debug->select dlleample->OK.

Step7:-   Double click on Getsum and Getmultiple button and write the following which are given below.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            dllexample.Class1 obj = new dllexample.Class1();
           int a=Convert.ToInt32(textBox1.Text);
            int b=Convert.ToInt32(textBox2.Text);
        obj.sum(a,b);
            
        }

        private void button2_Click(object sender, EventArgs e)
        {

            dllexample.Class1 obj = new dllexample.Class1();
            int a= Convert.ToInt32(textBox3.Text);
            int b = Convert.ToInt32(textBox4.Text);
            obj.multi(a,b);
        }
    }
}
see it:


Step7:- Now Run the program (press F5) ,the output of program is shown below :-
see it:-
.
For More:-
  1. File Handling Real Application
  2. Ado.Net Application
  3. Xml Application
  4. How to implement Web Form controls in asp.net
  5. How to implement caching and ajax feature in web services
  6. How to create constraints in ado.net application
  7. Navigation controls in asp.net
  8. Create setup file with database
  9. Projects on e-post system in asp.net
  10. How to Create data set and data adapter
  11. Abstract class and abstract method in c#
  12. How to use multiple main method in c#

I hope this is helpful for you.

 Download  whole Attached application.
     DOWNLOAD

6 comments:

  1. Thank you very much for you can share your post,the article content written very well,extremely is worth my study.

    ReplyDelete
  2. good post...

    ReplyDelete
  3. simple and good one, thx a lot...

    ReplyDelete
  4. It is possible to download missing DLL files from Fix4dll.com and avoid seeing the most expected error messages like "Msvcr110.dll is missing" or "D3dx9_39.dll is missing".

    ReplyDelete
  5. Thanks for sharing this informative blog. I am extremely happy to find this blog as it contains unique information on what I am finding for many days. You have briefly explained how to create a DLL File and using it in .NET application. I have read a blog few days back on DLL Files and How they actually work. I must say it is a worth reading blog!

    ReplyDelete

Powered by Blogger.