C#程序集Assembly学习随笔(第一版)_AX
2018-12-20 09:37 GarfieldEr007 阅读(365) 评论(0) 编辑 收藏 举报①什么是程序集?
可以把程序集简单理解为你的.NET项目在编译后生成的*.exe或*.dll文件.
嗯,这个确实简单了些,但我是这么理解的.详细:
http://blog.csdn.net/sws8327/archive/2006/09/21/1244642.aspx
②程序集和命名空间的区别?
一个程序集可以跨越n个命名空间,一个命名空间也可以包含n个程序集.(估计你该晕了)
如果说命名空间是类库的逻辑组织形式,那么程序集就是类库的物理组织形式。只有同时指定类型所在的命名空间及实现该类型的程序集,才能完全限定该类型。(摘抄自《精通.NET核心技术--原来与架构》 电子工业出版社)
也就是说,你要创建一个类的实例,必须知道该类的 命名空间(这个一般都知道)+程序集(这个很容易被我们忽略,因为一般我们不需要引用外部的程序集,如果你用C#做过Excel文件的导入导出,就会知道必须添加一个Excel相关的程序集引用)
③怎样通过命令行创建程序集?
我对命令行向来反感,如果你想知道,look here:
http://www.cnblogs.com/3echo/archive/2006/02/14/330579.html
④我怎么把项目和程序集联系起来理解?
一个项目对应一个程序集.项目名与程序集名相同(03版,05版乱七八糟,随机生成的程序集名).
一般的我们每创建一个.NET项目(ASP.NET(VS2005里没有),WinForm,类库,控制台等),IDE都会自动生成一个AssemblyInfo.cs的文件,打开看看(03版)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
汗,,[assembly: AssemblyTitle("")],,,,竟然程序集名是空的....不过你从该项目的文件夹里确实能翻出与项目名相同的.dll文件.估计如果你不在这条语句里赋值,IDE默认生成的程序集与项目名相同.大胆用吧.(可是,我不知道怎么用程序集?敬请期待下一篇:C#反射Reflection学习随笔_AX)
⑤自知,我的解决方案(包含0~n个项目)用到了什么程序集?
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
⑥我们苦苦寻觅的Assembly里面到底是什么东西?有什么值得我们去苦苦探究的?
其实在上面的AssemblyInfo.cs代码中,我们已经看出来一些东西,它里面包含该Assembly的名称/产品/描述/拷贝权..(鬼才关心)和版本号(这个很重要,但我觉得还是没什么太大的用处,是dll Hell 的克星,顺带说一句,同一Assembly名称的不同版本号的Assembly可同时运行),还有一个密钥的概念,共享程序集和部署用的,看了半天没看明白,就不误人子弟了.
那Assembly的主要用处是:
ⅰ与反射Reflection结合起来用,动态创建你所需要的类!!
ⅱ与反射Reflection结合起来用,获得Assemble里类的信息
(据可靠的小道消息说Assembly里存的是一张包含元数据类名什么的表)
ⅲ使用别人已封装好的类.
from: https://www.cnblogs.com/AXzhz/archive/2006/10/30/544601.html