对于知道的,可能很简单吧。
问题就是,假入不用VS.NET等工具,在安装了VS.net的框架(dotnetfx)后,如何编译一个.cs文件为dll文件?
另外假如不用工具的引入功能进行dll的导入,那我们如何用代码自己实现,也就是VS.net引入某个dll文件时相当于写了什么代码?
问题就是,假入不用VS.NET等工具,在安装了VS.net的框架(dotnetfx)后,如何编译一个.cs文件为dll文件?
另外假如不用工具的引入功能进行dll的导入,那我们如何用代码自己实现,也就是VS.net引入某个dll文件时相当于写了什么代码?
{
MemoryStream stream = new MemoryStream();
System.Drawing.Image TargetBitmap = new Bitmap( image, new Size( 500, 400 ) );
System.Drawing.Graphics TargetGraphics = System.Drawing.Graphics.FromImage( TargetBitmap );
TargetGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
TargetGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
TargetGraphics.Clear( Color.White );
TargetGraphics.DrawImage( image, new System.Drawing.Rectangle( 0, 0, TargetBitmap.Width, TargetBitmap.Height ), new System.Drawing.Rectangle( 0, 0, image.Width, image.Height ), System.Drawing.GraphicsUnit.Pixel );
TargetBitmap.Save( stream, ImageFormat.Jpeg );
TargetBitmap.Dispose();
TargetGraphics.Dispose(); return stream;
}
当解释操作系统命令行上给出的参数时,C# 编译器代码使用下面的规则: 参数用空白分隔,空白可以是一个空格或制表符。
^ 字符 (^) 未被识别为转义符或者分隔符。该字符在被传递给程序中的 argv 数组前,完全由操作系统的命令行分析器进行处理。
无论其中有无空白,包含在双引号 ("string") 中的字符串均被解释为单个参数。带引号的字符串可以嵌入在参数内。
前面有反斜杠的双引号 (\") 被解释为原义双引号字符 (")。
反斜杠按其原义解释,除非它们紧位于双引号之前。
如果偶数个反斜杠后跟双引号,则每对反斜杠中的一个反斜杠放置在 argv 数组中,并且双引号被解释为字符串分隔符。
如果奇数个反斜杠后跟双引号,则每对反斜杠中的一个反斜杠放置在 argv 数组中,双引号由其余的反斜杠“转义”,使原义双引号 (") 被放置在 argv 数组中。
命令行示例
编译 File.cs 以产生 File.exe:
csc File.cs
编译 File.cs 以产生 File.dll:
csc /target:library File.cs
编译 File.cs 并创建 My.exe:
csc /out:My.exe File.cs
通过使用优化和定义 DEBUG 符号,编译当前目录中所有的 C# 文件。输出为 File2.exe:
csc /define:DEBUG /optimize /out:File2.exe *.cs
编译当前目录中所有的 C# 文件,以产生 File2.dll 的调试版本。不显示任何徽标和警告:
csc /target:library /out:File2.dll /warn:0 /nologo /debug *.cs
将当前目录中所有的 C# 文件编译为 Something.xyz(一个 DLL):
csc /target:library /out:Something.xyz *.cs
csc /t:library xxx.cs 在相应目录下生成xxx.dll
引用xxx.dll
csc /r:xxx.dll xxx2.cs 编译xxx2.cs时引用xxx.dll