C#之程序集

 
程序集的定义:
           1.程序集是一个或多个托管模块,以及一些资源文件的逻辑组合。
           2.程序集是组件复用,以及实施安全策略和版本策略的最小单位。
           3.程序集是包含一个或者多个类型定义文件和资源文件的集合。在程序集包含的所有文件中,有一个文件用于保存清单。(清单是元数据部分中一组数据表的集合,其中包含了程序集中一部分文件的名称,描述了程序集的版本,语言文化,发布者,共有导出类型,以及组成该程序集的所有文件)。

 程序集的物理表现:
           1.可执行程序集:存在一个用于表示EXE的文件,这个文件是程序集的入口点。
           2.提供功能的程序集:存在一个用于表示DLL的文件,这个文件是程序集的入口点。

程序集和托管模块的关系:
           1.可以使用       csc   /t:module       type1.cs  
                                     csc   /t:module       type2.cs  
                                     这样就可以生成两个托管模块: type1.netmodule  type2.netmodule
          2.使用命令将模块集成到程序集中:
                                     csc  /out:xxx.dll       /t:library  /addmodule: type1.netmodule type2.netmodule xxx.cs
           这样就有了程序集xxx.dll:    它由xxx.dll type1.netmodule type2.netmodule 组成。xxx.dll代表了这组程序集。xxx.dll也可以是xxx.exe。也可以使用al来创建:
          Al /out:xxx.dll /t:library type1.netmodule type2.netmodule.
         3.卫星程序集:
                 3.1创建资源文件:MyResource.cn.Resx 或者MyResource.cn.txt
                 3.2使用命令resgen MyResource.cn.resx  MyResource.cn.resources 编译资源          
                 3.3   al.exe /culture:cn /out:"cn/HelloWorld.Resources.dll" /embed:"MyResources.cn.resources" /template:"HelloWorld.exe"           
                 3.4在主程序集HelloWorld中如何访问卫星程序集:
                    System.Resources.ResourceManager resources =
                    new System.Resources.ResourceManager("HelloWorld.Resources.MyResources",
                    System.Reflection.Assembly.GetExecutingAssembly());

                // Print out the "HelloWorld" resource string
                Console.WriteLine(resources.GetString("HelloWorld"));
               
                // Get the new culture name
                Console.Write(resources.GetString("NextCulture"));
                3.5部署主程序集和卫星程序集 
│  HelloWorld.exe
├─ko-kr
│      HelloWorld.resources.dll
├─it
│      HelloWorld.resources.dll
├─fr
│      HelloWorld.resources.dll
├─es
│      HelloWorld.resources.dll
├─en
│      HelloWorld.resources.dll
├─en-us
│      HelloWorld.resources.dll
└─de
       HelloWorld.resources.dll
通过AL工具来改变一个程序集的各种属性:
        可以参见AL的帮助
通过AssemblyInfo.cs文件来改变一个程序集的属性:
       这个文件中最重要的几个特性是:
              1、AssemblyVersion: 格式: Major Version ---- Minor  Version ------ Build  version ------  Revision
              2、[assembly: AssemblyCulture("")]   
              3、[assembly: AssemblyDelaySign(false)]
              4、[assembly: AssemblyKeyFile("")]
              5、[assembly: AssemblyKeyName("")]
      这几个各个程序集属性的探讨

将程序集组成各种应用程序,进行程序集的部署:
       不考虑应用程序的类型,可以将程序集的部署分为私有部署和全局部署。
       私有部署:
           1.本地应用程序的部署结构
                 AppDir
                   |---- App.exe
                   |---- App.exe.config
                   |-----AuxFilesDir
                             |------ xxx.dll
                             |------ yyy.dll
                  在App.exe.config中可以配置影响CLR寻找程序集路径的选项。
           2.Asp.net应用程序和XML Web服务应用程序
                对于asp.net Web窗口和XMLWeb服务应用程序,配置文件必须位于Web应用程序的虚拟根目录下,并且名称总是Web.config 。另外子目录也可以包含它们自己的Web.config文件,并继承上一目录的配置设置。
           3. 对于包含客户方空件、以微软的IE浏览器为宿主的程序集。(没有见过)
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值