Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,326 Categories: 12

Total Tutorial Views: 41,458,977

[C#] How to make your own .DLL function library

Tutorial Name: [C#] How to make your own .DLL function library  

Category: PC Tutorials

Submitted By: Skittle

Date Added:

Comments: 0

Views: 1,924

Related Forum: PC Building Forum

Share:

In this tutorial I will be showing you how to compile functions into a .DLL file that you can distribute for others to use.
For my example, my .DLL will have one function that adds two numbers together and returns the value.
First, you will need to create your project. Open up Visual Studio.
Click "New Project":

[ Register or Signin to view external links. ]

Select "Class Library", name it to whatever you want and press "Ok":

[ Register or Signin to view external links. ]

Once your project has been created, you will come to the screen where you will put your code:

[ Register or Signin to view external links. ]

The code for my function will be very simple; The user will pass two Integers, they will be added together and returned. Here is my code:

public int Add(int num1, int num2)
{
    return num1 + num2;
}

All you have to do is add your code into the main Class:

[ Register or Signin to view external links. ]

If I wanted to add more functions, all I would have to do is repeat:

[ Register or Signin to view external links. ]

I know that these functions are completely pointless, but they are just an example of what you can do.
Next, you will need to build your project into a .DLL file. This is slightly different to a normal program, you do not run it like an application, otherwise you will get this message:

[ Register or Signin to view external links. ]

This is because running the program will not open a form, or run a console window, it just stores procedures that are accessed by other programs. You need to Build the project. Go to the "Build" tab at the top, and click "Build Solution" (or use the KeyBind CTRL+SHIFT+B):

[ Register or Signin to view external links. ]

Your program has been successfully compiled into a .DLL library!
To find the newly-created file, go to your project folder and find it at "\bin\Debug\YourDLL.dll":

[ Register or Signin to view external links. ]

I will soon be adding another tutorial on how to use a .DLL as a reference in one of your programs.
If you need any help with, feel free to PM me

Ratings

Current rating: 3.50 by 8 users
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"[C#] How to make your own .DLL function library" :: Login/Create an Account :: 0 comments

If you would like to post a comment please signin to your account or register for an account.