How do I make a DLL in C#?

Hi there;

How do I make a DLL in C#?

Kind regards.
LVL 12
jazzIIIloveAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
A DLL is just a library of classes that can be used by other applications. They cannot run independently they have to be part of an EXE or web application or something else.

There is no point compiling a WinForms application or Console application to a DLL because you will not be able to run it. Visual Studio will let you do it, but that doesn't mean you should.
0
 
RickConnect With a Mentor Commented:
0
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
A DLL is simply the output of a "Class Library" project. When you go into Visual Studio and select File > New Project from the menu, one of the options will be "Class Library". Adding code to a "Class Library" project will create the DLL.

You will also get a DLL from building an Web Application project, but I don't think that is what you mean in this case.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
wdosanjosCommented:
What do you want to achieve? Or, how do you plan to use this DLL?
0
 
jazzIIIloveAuthor Commented:
what about console app?
0
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
A console app will produce an EXE rather than a DLL, as will a WinForms application.
0
 
RickCommented:
The 1st example was for a console app.
0
 
jazzIIIloveAuthor Commented:
clarification from my side:
ok, it seems I can create a dll file with C# Classlibrary. ok with that.

What I said above is that may I create dll file from console application/windows form application instead of C# Class library?

Kind regards.
0
 
wdosanjosCommented:
@jazzIIIlove, what's the indeded use for this DLL?  So we can provide the proper answer.
0
 
jazzIIIloveAuthor Commented:
just learning purpose, no intended use yet.

Kind regards.
0
 
wdosanjosConnect With a Mentor Commented:
I asked about the intended use, because VS provides different project templates that result in DLLs. So, depending on the need you should select the appropriate template.

Class Library
Windows Forms Control Library
WPF User Control Library
WPF Custom Control Library
Office Add-in (Excel, Word, Powerpoint, etc)
etc
0
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
You can tell Visual Studio to compile a console project as a DLL if you really wanted to, but Windows won't run it unless it is an EXE.
0
 
jazzIIIloveAuthor Commented:
wdosanjos:
Thanks for the very information.

carl_tawn:
>>A console app will produce an EXE rather than a DLL, as will a WinForms application.
But you can create a dll of a windows form application. Right?

carl_tawn:

>>You can tell Visual Studio to compile a console project as a DLL if you really wanted to, but >>Windows won't run it unless it is an EXE.

but a .NET project can run for it? I ask this to enhance the perception of mine to understand the very scope of a dll.

Kind regards.
0
 
jazzIIIloveAuthor Commented:
thanks for the clarification.

Kind regards.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.