Creating your own DLL files | Visual studio class library

preview_player
Показать описание

Learn how to create your own DLL files in C# using the visual studio Class Library.

DLL Stands for dynamic link library which is a file that contains code and data that can be used by more than one program at the same time.

By creating a C# class library, we are creating a package that can be included in our projects. This package contains code, like classes and methods, that we can use across multiple applications.

What is a Class Library?

By creating a C# class library, you are creating a package that can be included in your projects. This package contains code, like classes and methods, that you find useful enough to use across multiple applications.

When you build a C# class library, a .dll file is created. By referencing this DLL file in your other projects, you will be able to use the classes and methods contained within. You can also distribute your class library through package management repositories or through open-source projects to allow other developers to use the functions you have created.

When you build a typical C# project file, an executable .EXE file is generated. When you build a class library project, a .DLL file is created in the source directory. By simply adding a reference to this .DLL file, any of your projects will be able to take advantage of the custom classes and methods you have written.

Have you ever tried to run a game and then you got an error?

Well, you probably solved this issue by downloading some DLL files from a shady website and copied them to the game directory.

So what is a DLL file?
DLL stands for “Dynamic link library”

A dynamic link library is a library that contains code and data that can be used by more than one program at the same time.

Let’s discuss some of the advantages that you will get when you use a DLL file in your apps:

--Uses fewer resources

When multiple programs use the same library of functions, a DLL can reduce the duplication of code that is loaded on the disk.

---updates are easier to apply to each module without affecting other parts of the program. For example, you may have an accounting program, and the tax rates change each year. When these changes are isolated to a DLL, you can apply an update without the need to build or install the whole program again.
All you have to do is to replace the old DLL files with the newer one

--Eases deployment and installation

When a function within a DLL needs an update or a fix, the deployment and installation of the DLL do not require the program to be relinked with the DLL. Additionally, if multiple programs use the same DLL, the multiple programs will all benefit from the update or the fix.

--Encapsulation and reusability.

If you write some generally useful functionality (an XML parser, a communications layer, a device driver)

.If you make it a DLL file, you can drop in and invoke from anywhere, and also it's easier to maintain and test independently too.

tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Рекомендации по теме
Комментарии
Автор

I am try reading a lot of blog, but I couldn't find my answer until I watch this video. Thank you so much

nguyenthanhcong
Автор

Thank you. Always something new to learn here.

richardmeyer
Автор

very simple and clear, great tutorial

houssamalucad
Автор

Underrated video! This is cool, thanks!

JeersNX
Автор

Thank you, very well explained... greetings from Portugal

brunoromao
Автор

Was talking with my dad about programming and mentioning using DLL for C++ as well as C# and he just hated how he kept getting those same game error messages you mentioned.
He mentioned I once talked about a replacement for them. Wish I remembered what.

magnusm
Автор

To the point and very clear. Keep make content. U re content creator that needed to unviverse.

gabisaintro
Автор

i'm trying to make a managed dll that integrates libmodbus. the documentation for integrating libmodbus in CPP dll is present but its not present for c#. and when i reference the libmodbus dll that i created in CPP i ave to use dllimport for every function instead i want to be able to directly start using the functions just lie you did in your vid. Can you please tell me how i can make a managed dll with libmodbus. Thank you

AbhishekBade
Автор

Fantastic exactly what I was looking for.

cybersamurai
Автор

Thank you bro, your video is very helpful

muhamadguruh
Автор

Awesome video, sir. Short and clear. Thank you

Fernando-duuj
Автор

Thanks great video. Could you possibly do a video on how to manually (without Visual Studio, only using .Net framework) create a very simple c sharp dll and a c sharp executable which invokes the dll functionality? That would be much appreciated.

portaletradingit
Автор

does anyone know how to write a tooltip for the DLL?
i would like to add a short description of what the method does.

whitetiana
Автор

I am running Visual studio code and I do not have the build function. Every video I have watched, everyone has the build tab on the menu bar. I have File | Edit| Selection| View| Go| Run| Terminal |Help. That is it. What am I doing wrong?

Ronaldo-ipcf
Автор

Your video is really helpful. I'm having a ques. like in my project there are multiple .cs files in one folder. Can I create Class library for those .cs files or create a NuGet package for it? As I cannot see anywhere it is mentioned that we can create class library with multiple .cs files.

zyuqucj
Автор

@TutorialsEU Currently I have a existing DLL file that I'm trying to copy to create a new DLL file however for the new file I want it to be for a Windows 32bit system how do I do this in visual studio if you have this information that would be helpful.

ravev
Автор

I created .cs classes in Models & controllers for my contact us form but I already publish package to server without contact form files, So I want to share my .dll files of contact us form to my website database. How I differentiate ?

sultanbyn
Автор

isn't better if we build our dll as production and use that instead of debug dll file?

RobertNicjoo