How to generate EXE and DLL files from CS files compiled into DLL files
The following is my production process:
1. There is a test. CS file under drive E.
2. Start-Program-Microsoft Visual Studio 2005-Visual Studio Tools-Visual Studio 2005 Command Prompt
3. Run the following command prompt: CSC/Target: Library/out: e:/mytestdll. dll E:/test. CS.
You can generate a DLL file named mytestdll on the E disk. The topic of this DLL is test. CS.
Note:
This error occurs when I generate my own dll:
E:/dotnetbarcode. CS (8, 29): Error cs0234:
The namespace "Microsoft. VisualBasic" does not contain a type or namespace name "compilerservices" (is the Assembly reference missing ?)
This is because the eighth line of my class references "using Microsoft. VisualBasic. compilerservices;"; however, vs2005c # program cannot reference the class library in VB. So an error is reported.
My solution is:
Find the path of the VB class library on my computer and introduce the compilation.
/Reference: C:/Windows/Microsoft. NET/framework/v2
. 0.50727/Microsoft. VisualBasic. dll
The complete statement is as follows:
CSC/Target: Library/out: e:/mytestdll. dll e:/test. CS/reference: C:/Windows/Microsoft. net/framework/v2.0.50727/Microsoft. visualBasic. DLL
I hope you can solve the problem! The following is an excerpt:
1. Open Microsoft. NET Framework SDK V2.0 --> SDK Command Prompt
2. Specify the directory where the CS file is located (such as E :)
3. Run the command CSC /? View All commands and Their Parameters
4. CSC/Target: EXE *. CS (generate the EXE file) ----/T: EXE *. CS (short form)
5. CSC/Target: Library *. CS (DLL file generation) --/T: Library *. CS (short form)
The search results on the Internet are generally not detailed. This is more detailed and the experiment is successful.
Now, how can I call this DLL?
It seems that. NET is well called. Can ASP call it?
Can other languages be called?
You can call the C # compiler on the command line by typing the name of the C # compiler Executable File (csc.exe. If you want to call csc.exe from any subdirectory on your computer, you may need to adjust the path.
Command Line syntax rules
When interpreting the parameters given on the operating system command line, C # compiler Code uses the following rules:
Parameters are separated by spaces. The blank space can be a space or tab.
^ Character (^) is not recognized as an escape character or separator. This character is completely processed by the command line analyzer of the operating system before it is passed to the argv array in the program.
A string contained in double quotation marks ("string") is interpreted as a single parameter no matter whether it is blank or not. Strings with quotation marks can be embedded in parameters.
Double quotation marks (/") with a backslash are interpreted as the original double quotation marks (").
The backslash is interpreted as its original meaning unless they are placed before double quotation marks.
If an even number of backslashes are followed by double quotation marks, each pair of backslashes is placed in an argv array, and double quotation marks are interpreted as string separators.
If an odd number of backslashes are followed by double quotation marks, each pair of backslashes is placed in the argv array. The double quotation marks are "escaped" by the remaining backslashes to make the original double quotation marks (") is placed in the argv array.
Command Line example
Compile file. CS to generate file.exe:
CSC file. CS
Compile file. CS to generate file. dll:
CSC/Target: library file. CS
Compile file. CS and create my.exe:
CSC/out: my.exe file. CS
Compile all C # files in the current directory by optimizing and defining the debug symbol. Output is file2.exe:
CSC/define: Debug/optimize/out: file2.exe *. CS
Compile all the C # files in the current directory to generate the debug version of file2.dll. No logo or warning is displayed:
CSC/Target: Library/out: file2.dll/warn: 0/nologo/debug *. CS
Compile all the C # files in the current directory as something. XYZ (a DLL ):
CSC/Target: Library/out: Something. XYZ *. CS