473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to create a simple dll in C# (Visual Studio 2005)

Hi
this time I am interested in console applications only.
Now I need to create a simple .dll. How to do that? I am totally newbie in
dll creation so be patient ;) I have searched internet but I still do not
understand few things. please tell me how to write a very simple dll
containing only a function that writes a text on console. the text will be a
paremetr of this function. how to use that .dll in other applications.
any help will be really appreciated!
Aug 16 '06 #1
4 31822
Create a class library project and write a simple class containing only
a function. you should make sure that you have added access control on
the function with PUBLIC. Now, create another console applicaiton and
add project reference from class library project.
You can invoke the function here after initializing a new instance of
the simple class.

Find more information at MSDN.

Sincerely,
simida
Chris wrote:
Hi
this time I am interested in console applications only.
Now I need to create a simple .dll. How to do that? I am totally newbie in
dll creation so be patient ;) I have searched internet but I still do not
understand few things. please tell me how to write a very simple dll
containing only a function that writes a text on console. the text will be a
paremetr of this function. how to use that .dll in other applications.
any help will be really appreciated!
Aug 16 '06 #2
OK; procedure is as below; however, note that I wouldn't recommend writing
to the console from a dll except for trivial apps; the design principle of a
dll is that it could be consumed from various projects, which may or may not
have a console window attached - so generally I would only write to the
console from the UI (the console exe), with the dll conveying messages back
to the exe via some combination of interfaces, streams, events, trace, or
suchlike.
1: create the two projects
Create a new Console Application (exe) project (File -New Project) and
then add a Class Library (dll) project (File -Add -New Project).
2: reference the dll from the exe
In the solution explorer of the console app, right-click on References ->
Add Reference...; on the Projects tab select the class library project
(note; different reference types are available)
3: write some code in the dll
e.g. in the Class1.cs that the designer provides:
namespace ClassLibrary1 {
public class Class1 {
public static void WriteSomething(string something) {
Console.WriteLine(something);
}
}
}
4: consume that method from the exe, e.g. in the Program.cs that the
designer provides:
static class Program { // I have tweaked these slightly for simplicity
static void Main() {
ClassLibrary1.Class1.WriteSomething("abc");
}
}

5: test
You should see abc written to the console
Aug 16 '06 #3
how can i make simple dll in visual studio 2005 so that i make my one
db class namespace in one dll

Sep 9 '06 #4
<ri*********@gmail.comwrote:
how can i make simple dll in visual studio 2005 so that i make my one
db class namespace in one dll
Just create a new Class Library project and put your classes in that -
the output of that will be a DLL.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: JonSteng | last post by:
..Net Visual Studio Professional 2003 Version 7.1.3088 ..Net Framework 1.1 SP1 Version 1.1.4322 IIS 5.1 Windows XP Professional SP2 Micron T3000 Laptop (1.5 GHz; 1GB RAM; 40GB HD with 17GB Free)...
2
by: Progman | last post by:
I have Visual Studio 2005 Standard edition. Is ti the same thing as the Express edition or Standard is more?
10
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
4
by: hellCoder | last post by:
Hi, I'm facing a nightmare here... I had Visual Studio 2003 installed and working perfectly but I decided to install Visual Studio 2005 just to begin to use it. The installation of the VS 2005...
8
by: WT | last post by:
Is it normal that Visual Studio sets the PreInit handler for a Page from the OnInit code ? No chance to fire it as OnPreInit is run befor OnInit. ??? CS
3
by: Edwin Smith | last post by:
I have a 2 form project in VS2005 that now hangs whenever I try to do anything with the second form. This seems to have started when I added some SQL tables from a Pervasive v.9 database using the...
11
by: raylopez99 | last post by:
Keep in mind this is my first compiled SQL program Stored Procedure (SP), copied from a book by Frasier Visual C++.NET in Visual Studio 2005 (Chap12). So far, so theory, except for one bug...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
8
by: ftjonsson | last post by:
hello, I was wondering if anyone could tips me on what I am doing wrong when writing the following code: #include <iostream> using namespace std; int main () {
13
by: miztaken | last post by:
Hi, My C# application have a following code to create an instance of Visual Studio. System.Type type = System.Type.GetTypeFromProgID("VisualStudio.DTE. 8.0"); Object obj =...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.