473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,385 developers and data experts.

How to Create a C# DLL file using Visual Studio 2010

We create our c# dll file using the visual studio 2010.

So first from file menu select the project option, then
select the class library,named it as you wish after cliking ok by default a classlibrary1 has created and inside that a class1 also created.

Inside this class1 you should placed your methods which you wish to use in other project files. After creating the class you should build it.To build it you must save the file first then from build menu select build> build classlibrary1.

After a successful build,you close this file, and open a new project where you wish to use this dll. From the project menu select add reference,the add reference window will shown , then choose the browse button and browse the dll file where you store it for example-> projects->classlibrary1->bin->debug or bin->release and locate the dll file. Now you able to use it in your project.

You must call the namespace, to use the methods inside the dll.( using namespace_name;)

Here we use the createdll the dll file
Expand|Select|Wrap|Line Numbers
  1. using System.Drawing;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using createdll;
  6. namespace WindowsFormsApplication2
  7. {
  8.     public partial class Form1 : Form
  9.     {
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         private void button1_Click(object sender, EventArgs e)
  16.         {
  17.             try
  18.             {
  19.                 long a, b;
  20.                 a = long.Parse(textBox1.Text);
  21.                 b = long.Parse(textBox2.Text);
  22.                 textBox3.Text = math.add(a, b).ToString();
  23.             }
  24.             catch (Exception ex)
  25.             {
  26.                 MessageBox.Show(ex.Message);
  27.             }
  28.         }
  29. }
Here a simple example of class inside the dll file.
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ClassLibrary1
  7. {
  8.     public class Class1
  9.     {
  10.         public static long add(long a, long b)
  11.         {
  12.             return (a + b);
  13.         }
  14.     }
  15. }

Note: After successful build of this class will create a dll file( here ut ClassLibrary1.dll
Nov 15 '11 #1
1 73994
Thanks Buddy to sharing very informative post. I would like to appreciate you for sharing this post.I have found another nice post related to this post over the internet which also explained very well. Check this.Creating C# Class Library (DLL)
Sep 23 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jabailo | last post by:
These guys have it going on. They actually use design ideas that Microsoft employees can drool upon. Visual Studio 2010 Concept IDE http://www.codeproject.com/csharp/Concept_IDE.asp "Like...
3
by: Kieran Kelly | last post by:
Is it possible to create a new Web Application Project using Visual Studio.Net 2003 on Windows 2003 Server but no in the Default Web Site. 1. I have created a new Web Site in IIS called WebSite2...
10
by: Frankie | last post by:
I am looking for tutorials, articles, etc that can help to enlighten me on what's "really going on" or what's required to create a .NET application (particularly Windows Forms) WITHOUT the use of...
2
by: Geek | last post by:
Guys, I have a question regarding publishing web site using visual studio 2005. As usual I am running in to issues using visual studio 2005. I have build a web site and when I publish to the...
2
by: Nathan Sokalski | last post by:
I have a webhost that unfortunately does not yet support ASP.NET 2.0. This would not be a problem, except for the fact that most places no longer sell Visual Studio .NET 2003, which means I need to...
1
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Visual Studio 2010 and .NET Framework 4.0 Overview URL:http://msdn.microsoft.com/en-us/vstudio/products/cc948977.aspx Regards Kerem -- ----------------------- Beste Grüsse / Best regards...
0
by: garbmail10 | last post by:
Hallo to all I'm using visual studio 2010 c# on windows 7 In a program i use SpeechLib (located in C:\Windows\System32\Speech\Common\sapi.dll) with SpVoice voice = new SpVoice();...
0
by: Jourdan | last post by:
I am creating a web application backed by a SQL database in visual studio 2010. I have created a form with a dropdownlists for date and category as well as a textbox to perform a key word search. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.