2008年9月11日星期四

如何将一个类(.cs)文件编译成.dll文件


1、写好代码先,编译成DLL文件,用C#写的CS文件需要用Framework中的CSC命令编译,编译步骤为:

2、在命令工具中输入 csc /t:library /r:System.Web.dll /r:System.dll /out: 目标文件名 源路径\源文件名。

  csc /target:library /out:e:\cyc\asp.Net\words\database.dll e:\cyc\asp.Net\words\as.Net2.0news\app_code\compon.Nets\databse.cs

3、为避免每次编译的麻烦,可以建立cmd文件如csd_dl.cmd  ,代码如下:

cd\

d:

cd D:\sys03\microsoft.Net\framework\v1.4322

csc  /t:library  /r:System.Web.dll  /r:System.dll /out:E:\web\bin\WebTools.dll e:\web\bin\DbLink.cs

cmd

 -   输出文件   -  

  /out:<file>                           输出文件名(默认值:   包含主类的文件或第一个文件的基名称)  

  /target:exe                           生成控制台可执行文件(默认)   (缩写:   /t:exe)  

  /target:winexe                     生成   Windows   可执行文件   (缩写:   /t:winexe)  

  /target:library                   生成库   (缩写:   /t:library)  

  /target:module                     生成能添加到其他程序集的模块   (缩写:   /t:module)  

  /define:<symbol   list>       定义条件编译符号   (缩写:   /d)  

  /doc:<file>                           要生成的   Xml   文档文件  

没有评论: