473,796 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 31840
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.WriteLi ne(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.C lass1.WriteSome thing("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*********@gm ail.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.co m>
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
3379
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) I installed FrontPage server extensions to IIS on my computer while following instructions in a Microsoft ASP.Net MCSD training book. After installing the FrontPage Server Extensions I cannot create a new
2
3447
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
8206
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 everything I can find on COM Interop and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site relating to COM add-ins, .NET and Office XP but am unable to get even these working in Excel 2002 or Word 2002. I've installed the Office XP...
4
2029
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 finished successfully but since then I cannot create or open any asp.net web application. I receive the following message: "Unable to create Web project 'ProjectName'. The file path 'FilePath' does not correspond to the URL 'ProjectURL'. The...
8
6273
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
6064
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 Pervasive ODBC driver. The devenv.exe process hangs and will not respond with about 50% cpu usage and about 100 megs of memory used. I am running it on an Athlon 64 bit dual core with 32 bit Windows XP pro. I have 2 megs of memory so I don't...
11
4101
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 (feature?) below. At some point I'm sure I'll be able to laugh about this, akin to forgeting a semi-colon in C/C++, but right now it's frustrating (time to sleep on it for a while). Problem-- For some reason I get the error when trying to save files...
1
3602
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 some files and work on it. Let say, I want add new page to web project named websiteOrder.sln, i will open websiteOrder.sln in my local computer, connected to websiteOrder.sln located in Visual Source Safe 6.0(source safe located in another...
8
3179
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
3747
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 = System.Activator.CreateInstance(type, true); EnvDTE80.DTE2 dte8Obj = (EnvDTE80.DTE2)obj; MessageFilter.Register(); dte8Obj.MainWindow.Visible = false;
0
9680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10456
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.