Loading...

Use a DLL in c# Simple and Easy Tutorial with Helping Pictures Guide

Attach a DLL in C# with the Program with the Help of Pictures 

Hi Friends, Today I am going to give you a simple tutorial about how to attach a DLL with a C# Program. and how to call methods or Functions of a DLL.

What is DLL?

DLL is a abbreviation of Dynamic Link Library. DLL is a executable file that allow to share its code or resources with any Program to which it is connected.  Usually DLL Contains Functions or Methods and Resources that are used by the Program.

How to Attach or work with DLL?

It is simple: Steps are given below.
1. Open Visual Studio new project
2. Select Class Library 

3. Make a method/Function in default Class and build the Program using F6 key (it cannot be debugged)
e.g
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DLL
{
    public class Class1
    {
        public string DLL_Practice(string name)
        {
            return "Assalam u Alaikum " + name;
        }
    }
}
4. Open Console Application on another Window of Visual Studio.
5. Go to Solution Explorer and do right click on references to ADD Reference.


6. Browse the DLL and go to its Debug Folder where u will see a .dll File.
7. Add using statement 
e.g 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DLL; (DLL is the name of DLL I made)
8. Create the object of DLL class in Console Program
e.g
 class Program
    {
        static void Main(string[] args)
        {
            Class1 c1 = new Class1();
           Console.WriteLine(c1.DLL_Practice("Faisal"));
        }
    }
9. Run the Program and Enjoy :) 

OUTPUT


Hit the Facebook like button below if you like this article... this helps a lot and keep us motivated :)

Newer Post
Previous
This is the last post.

Google+

 
TOP