Visual C # generate DLL file favorites
Prerequisites
A dll (Dynamic Link Library) file is an executable file that allows programs to share the code and other resources necessary to execute special tasks. In most cases, the dll extension (or. ocx file: ActiveX control file ,. cpl file: control panel file ,. DRV files: device driver files), providing code, data, or functions to programs running in windows.
Some benefits of using DLL:
Use fewer resources;
Promote modular architecture;
Simplify deployment and installation.
Http://support.microsoft.com/kb/815065/zh-cn)
A dll is not a program that runs independently. It is a part of a program and can only be called by the program to which it belongs. You cannot open it.
Visual C # generate a DLL file
After compiling a DLL file written in Visual C, Delphi, or VB, the generated DLL file is already a binary file that can be directly used by the computer. However, although the managed code generated using the Visual C # compiler is also a binary file, it is not the original code that can be directly used by computers. It is essentially an intermediate language (IL) code, you need to go through the "next-generation window service" (next
Generation Windows Services, abbreviated as ngws) Real-time Compiler (JIT) for runtime compilation.
The DLL file generated with Visual C # is essentially different from the previous DLL file. The DLL files generated using Visual C # Are more represented by a class or class library in programming ).
Create a component
1. First create a new class library project file
File-> New-> Project-> Visual C # projects-> class library. Enter the project file name and select the directory where the file is to be stored.
2. engineering documents
Rename class1.cs as the file name to be created: mydll. CS and enter the code.
3. Generate the DLL file
Compile the project file CSC/Target: Library/out: mydll. DLL mydll. CS generation component mydll. DLL, which is located in the bin \ DEBUG directory of the project file. The file extension is DLL.
Test DLL
1. Create a new control application
File-> New-> Project-> Visual C # projects-> console application. Use this control application to test our components.
2. Add reference for namespace
Project-> Add reference, browse to the generated DLL, and then press OK. The class that will be referenced to the current project file.
3. Call the mydll namespace, create a mydll object, and call its methods and properties.
(1) Use namespace: Using mydll;
(2) create a mydll object;
(3) Call methods and attributes.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lpy123456/archive/2007/11/16/1887655.aspx