Click here to Skip to main content
11,925,381 members (64,741 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Visual-Studio DLL
I have googled this thing and found lots of solution;
I have already used class so have idea about i want to use my own DLL.
After creating the class everyone suggest me to do the following

Go to the command line and type the following.

CSC /target:library /out:MyFunctions.dll AddClass.cs
MultiClass.cs FactorialClass.cs

Go to the command line option /target:library and ask the C Sharp Compiler/Linker to output a DLL instead of an EXE. It's possible to have a different name for the DLL; for example, /out:MyFunctions.dll directs the compiler to output the DLL with the name MyFunctionsLib; otherwise, it will take the default name from the first .cs file. Here, it's AddClass.dll.

I am not getting this above thing..can anyone please help me understand this thing.
Thanks in advance.
Posted 5-Sep-12 2:02am
Edited 5-Sep-12 2:09am
Wes Aday 5-Sep-12 7:14am
Understand what "thing"? Why are you even using the command line? What aren't you creating a project in the IDE?
biswarup88 5-Sep-12 7:22am
i have never used command that i didn't get this..
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hello ,

To build the file MyFunctions.DLL, compile the two files Add.cs and Mult.cs using the following command line:
csc /target:library /out:MyFunctions.DLL Add.cs Mult.cs
The /target:library compiler option tells the compiler to output a DLL instead of an EXE file. The /out compiler option followed by a file name is used to specify the DLL file name. Otherwise, the compiler uses the first file (Add.cs) as the name of the DLL.

To build the executable file, TestCode.exe, use the following command line:
csc /out:TestCode.exe /reference:MyFunctions.DLL TestCode.cs
The /out compiler option tells the compiler to output an EXE file and specifies the name of the output file (TestCode.exe). This compiler option is optional. The /reference compiler option specifies the DLL file or files that this program uses.

Please refer URL ([^]) for more details
biswarup88 5-Sep-12 7:26am
I have found this above content after googled this topic .. i want to know how to build dll using command line..
aspnet_regiis 5-Sep-12 7:36am
Did you read the solution 1? prashant is telling you in details the method to build a dll with 'command line' itself.... not the IDE.....
Rahul Rajat Singh 5-Sep-12 7:49am
good answer. +5.
biswarup88 5-Sep-12 8:12am
aspnet_regiis can you please tell me in details how to compile the two files Add.cs and Mult.cs using command line? That i can't understand...though the problem is solved using solution3..but i want to know solution1
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

If you are using Visual Studio you can do by following steps:
1. Open your project.
2. Go to your solution explorer.
3. Right click on your project name and select properties tab.
4. Go to Application tab and find 'output type' option.
5. Click on output type and select class library.
6. Save and Close properties window.
7. Build your project you will find dll files in debug folder of your project.
8. Now you can coopy your dll to and project or include them in any project you want.
biswarup88 5-Sep-12 8:10am
Thanks all for your co-operation..
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Prashant has given the solution to do it from command line. I still don't understand why would you not use the IDE. In case you want to use the IDE to do the same refer to the following solution:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 5 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100