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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RickCommented:
0
Carl TawnSystems 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
wdosanjosCommented:
What do you want to achieve? Or, how do you plan to use this DLL?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

jazzIIIloveAuthor Commented:
what about console app?
0
Carl TawnSystems 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
wdosanjosCommented:
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 TawnSystems 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
Carl TawnSystems 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jazzIIIloveAuthor Commented:
thanks for the clarification.

Kind regards.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.