使用Visual Studio将C#生成DLL文件的方法 使用Visual Studio将C#生成DLL文件的方法

使用Visual Studio将C#生成DLL文件的方法

1.命令方式

打开Visual Studio安装目录下的开发人员命令提示

译 File.cs 以产生 File.exe

csc File.cs 编译 File.cs 以产生 File.dll 
csc /target:library File.cs 编译 File.cs 在该目录下产生一个对应名字的.dll文件
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文件里 

csc不是内部或外部命令,也不是可运行的程序解决方法

针对VisualStudio2005
1:右键点击"我的电脑"--"属性"--"高级"--"环境变量"--"系统变量"
将PATH中加上路径:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
2:直接在dos环境的cs相应文件夹目录执行
Path=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
3:VisualStudio2005命令提示
开始--》程序---》Microsoft Visual Studio2005---->Visual Studio Tools--->VisualStudio2005命令提示
把cs文件copy到C:\Program Files\Microsoft Visual Studio 8\VC\
4:C:\autoexec.bat
加入:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\

vs2008 下
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ 里的CSC.EXE 是2.0版本
编译的.cs文件如果带using System.Linq;编译通不过,如果不用LINQ语法删除using System.Linq;即可,否则 调用C:\WINDOWS\Microsoft.NET\Framework\v3.5里的CSC.EXE

同一SLN下 里面 class 直接访问类库。
封装到DLL。 导入DLL 添加using namespace 工有才能访问。

1.工具方式

直接在Visual Studio开发软件里面生成

扫描二维码关注公众号,回复: 7421029 查看本文章

 转载自https://www.cnblogs.com/AaronBlogs/p/6840283.html

1.命令方式

打开Visual Studio安装目录下的开发人员命令提示

译 File.cs 以产生 File.exe

csc File.cs 编译 File.cs 以产生 File.dll 
csc /target:library File.cs 编译 File.cs 在该目录下产生一个对应名字的.dll文件
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文件里 

csc不是内部或外部命令,也不是可运行的程序解决方法

针对VisualStudio2005
1:右键点击"我的电脑"--"属性"--"高级"--"环境变量"--"系统变量"
将PATH中加上路径:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
2:直接在dos环境的cs相应文件夹目录执行
Path=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
3:VisualStudio2005命令提示
开始--》程序---》Microsoft Visual Studio2005---->Visual Studio Tools--->VisualStudio2005命令提示
把cs文件copy到C:\Program Files\Microsoft Visual Studio 8\VC\
4:C:\autoexec.bat
加入:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\

vs2008 下
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ 里的CSC.EXE 是2.0版本
编译的.cs文件如果带using System.Linq;编译通不过,如果不用LINQ语法删除using System.Linq;即可,否则 调用C:\WINDOWS\Microsoft.NET\Framework\v3.5里的CSC.EXE

同一SLN下 里面 class 直接访问类库。
封装到DLL。 导入DLL 添加using namespace 工有才能访问。

1.工具方式

直接在Visual Studio开发软件里面生成

 转载自https://www.cnblogs.com/AaronBlogs/p/6840283.html

猜你喜欢

转载自www.cnblogs.com/xiaoahui/p/11621056.html