有时候为了某种需要,为了代码的安全,我们经常将.cs文件单独编译成.dll文件,其操作如下:打开命令窗口->输入cmd到控制台->cd C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322转到vs.net安装的该目录下->执行csc命令csc /target:library File.cs->在该目录下产生一个对应名字的.dll文件(前提:把.cs文件放到C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322目录下)
csc命令的方式很多,请参考以下,------------------------------------译 File.cs 以产生 File.exe: csc File.cs 示例:编译c:\File.cs以生成c:\File.dll csc /target:library c:\File.dll c:\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 编译 File.cs 以产生 File.dll: csc /target:library File.cs这个就是我们使用最多的一个命令,其实可以简单的写成csc /t:library File.cs,另外的一个写法是csc /out:mycodebehind.dll /t:library mycodebehind.cs,这个可以自己指定输出的文件名。csc /out:mycodebehind.dll /t:library mycodebehind.cs mycodebehind2.cs,这个的作用是把两个cs文件装到一个.dll文件里,非常实用!!!
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18