Solved

How do I make a DLL in C#?

Posted on 2011-03-08
15
270 Views
Last Modified: 2012-05-11
Hi there;

How do I make a DLL in C#?

Kind regards.
0
Comment
Question by:jazzIIIlove
  • 5
  • 4
  • 3
  • +1
15 Comments
 
LVL 13

Assisted Solution

by:Rick
Rick earned 143 total points
ID: 35074190
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 286 total points
ID: 35074220
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
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35074225
What do you want to achieve? Or, how do you plan to use this DLL?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 13

Assisted Solution

by:Rick
Rick earned 143 total points
ID: 35074226
0
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35074232
what about console app?
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 286 total points
ID: 35074244
A console app will produce an EXE rather than a DLL, as will a WinForms application.
0
 
LVL 13

Expert Comment

by:Rick
ID: 35074249
The 1st example was for a console app.
0
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35075131
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
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35075151
@jazzIIIlove, what's the indeded use for this DLL?  So we can provide the proper answer.
0
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35075934
just learning purpose, no intended use yet.

Kind regards.
0
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 71 total points
ID: 35076828
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
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 286 total points
ID: 35080163
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35089254
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
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 286 total points
ID: 35092742
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35093256
thanks for the clarification.

Kind regards.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question