Compile the CS file into a DLL in Asp.net

Source: Internet
Author: User

The DLL file compiled last time is in the same directory as the CS file, instead of in the bin directory of the virtual directory.

The file is compiled into a DLL and automatically stored in the bin folder of the virtual directory?

Start ------- program ------- MicrosoftVisualStudio. NET2003 ------- visualStudio. NET tool, click "visualStudio. net2003 command prompt, you will enter MicrosoftVisualStudio. NET2003 Command Prompt window, then we use the doscommand (CD) to enter the directory where the CS file to be compiled into the DLL is located, and then enter the command:

CSC/Out:Bin \ index. dll/T: LibraryIndex. CS

Press enter to generate a DLL file with the same name as the CS file in the bin directory.

However, if this CS file references another DLL file under the bin directory, such as comman. dll, enter the following command:

CSC/Out:Bin \ index. dll/R:Bin \ comman. dll/T: LibraryIndex. CS

Here is an example of my own Compilation:

First, go to MicrosoftVisualStudio. NET2003 Command Prompt window, switch to drive C under command line (I put mousegridview. CS under drive C)

Run

C: \> CSC/Out: Mouseover. dll/T: LibraryMousegridview. CS

On the operating system where Microsoft. NET Framework is installed, you can find the Microsoft. NET directory in the directory where windows is located. The C # compiler, CSC. EXE, is provided under this directory.
Run: CSC/Target: Library/out: mydll. dll myswap. CS mymaxcd. CS
After that, you can find the mydll. dll file we just generated in the directory.
/Target: the Library compiler option notifies the compiler to output the DLL file instead of the EXE file. The/out compiler option followed by the file name is used to specify the DLL file name.
If the/out file is not followed by the file name compiler, use the first file (myswap. CS) as the DLL file name. The generated file is myswap. dll.
OK! The task of creating a dynamic link library file is complete. Now we are enjoying the fruits of our work. Next I will introduce how to use the dynamic link library file we created. </Font>

CSC/Target: Library/out: F: \ mydll. dll D: \ home \ myswap. Cs D: \ home \ mymaxcd. CS

Dynamic Links have the following advantages:

Saves memory and reduces swap operations. Many processes can use a DLL at the same time and share a copy of the DLL in the memory. On the contrary, for each application generated using a static Link Library, windows must load a copy of the library code in the memory.
Saves disk space. Many applications can share a copy of the DLL on the disk. Instead, each application generated with a static Link Library has the library code linked to its executable image as a separate copy.
It is easier to upgrade to DLL. When a function in DLL is changed, as long as the parameters and return values of the function are not changed, you do not need to re-compile or re-link their applications. On the contrary, static linked Object Code requires that the application be relinked when the function is changed.
Provide after-sales support. For example, you can modify the display driver DLL to support displays that are unavailable when the application was originally delivered.
Multi-language programs are supported. As long as the program complies with the function call conventions, the program written in different programming languages can call the same DLL function. Programs and DLL functions must be compatible in the following aspects: the order in which the function expects its parameters to be pushed to the stack, whether the function or application is responsible for clearing the stack, and whether any parameters are passed in the register.
Provides a mechanism to expand the MFC Library Class. You can use the existing MFC class derived classes and place them in the MFC extension DLL for the MFC application.
This makes it easy to create international versions. By putting resources in the DLL, it is much easier to create an international version of the application. Strings of each language version used for applications can be placed in a separate DLL resource file, and appropriate resources can be loaded for different language versions.
One potential disadvantage of using DLL is that the application is not independent; it depends on whether there is a separate DLL module.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.