JUST DO IT ~

          我只想當個程序員

          認識 : 看了 淺談.NET中的版本管理 ildasm.exe MyForm.exe

          看了  淺談.NET中的版本管理
          http://www.microsoft.com/china/community/program/originalarticles/techdoc/DOTNETVersion.mspx


          GAC:
          計算機范圍內的代碼緩存,它存儲專門安裝的程序集,這些程序集由計算機上的許多應用程序共享。在全局程序集緩存中部署的應用程序必須具有強名稱,一個程序集如果注冊到了GAC里,被其他程序集合引用的時候,將不會拷貝副本到引用的程序目錄中。 (本文只討論注冊到GAC中的程序集)

          實際就是  system32\ 目錄的做的作用, 系統安裝一份 就可以了,
          其他的程序要用 , 直接到界面上去引用, 不會有任何問題. 在系統 using 直接調,  ------反正就是不需要注冊組件文件拷貝.............
          如果沒有 代碼緩存 ...必須要自己注冊dll 文件 然后程序來引用

          好處 : 

          1 多版本維護替換dll

          他的另外一個作用在文中提及,就是可以進行多個版本注冊....... 使用的程序是 1.0dll編譯的 ..在升級到GAC到第二版dll ..................使用的程序不需要重新編譯,只要對 config 文件進行版本替換就可以的....
          這個是比較好的特點,允許我們輕松處理dll的版本
          雖然COM中 使用注冊表和 也能做到這點 dll     但是好像很復雜 .....

          2.實現簡單......
            步驟   
          1//首先生成強名稱到文件中
          sn –k c:\Version.snk2  //寫類文件
          v1.cs
          using System;
          using System.Reflection;
          [assembly: AssemblyKeyFile(@"c:\Version.snk")] //因為注冊到GAC,所以使用強名稱簽名
          [assembly: AssemblyVersion("1.0.0.0")] //設置版本號
          namespace V1 {

           3 匯編查看代碼

              D:\c_\forms>ildasm.exe MyForm.exe
          匯編 虛擬機代碼 看實質


          ame是程序集的名稱 publicKeyToken是公匙的標記;

          // Metadata version: v2.0.50727
          .assembly extern /*23000001*/ 'System.Windows.Forms'
          {
            .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
            .ver 2:0:0:0
          }

          打開%SystemDir%\assembly


          替換dll 不要拷貝文件

          TestVersion.exe.config里面打入
          <?xml version="1.0"?>
          <configuration>
          <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
          <assemblyIdentity name="V1" publicKeyToken=" 758fe4e9db9d8251"/>
          <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
          </assemblyBinding>
          </runtime>
          </configuration>
          











          大致對 dotnet下同版本理解

          DotNet中的版本由4個物理號碼組成,如圖(一)
          Assembly Info 的參數理解

          描述整個程序 版本名稱,
          版本號碼 GUI


          using System.Reflection;
          using System.Runtime.CompilerServices;
          using System.Runtime.InteropServices;

          // General Information about an assembly is controlled through the following 
          // set of attributes. Change these attribute values to modify the information
          // associated with an assembly.
          [assembly: AssemblyTitle("NHibernateWithAccess")]
          [assembly: AssemblyDescription(
          "A sample application showing how to use NHibernate with Access/Jet")]
          [assembly: AssemblyConfiguration(
          "")]
          [assembly: AssemblyCompany(
          "")]
          [assembly: AssemblyProduct(
          "NHibernateWithAccess")]
          [assembly: AssemblyCopyright(
          "")]
          [assembly: AssemblyTrademark(
          "")]
          [assembly: AssemblyCulture(
          "")]

          // Setting ComVisible to false makes the types in this assembly not visible 
          // to COM components.  If you need to access a type in this assembly from 
          // COM, set the ComVisible attribute to true on that type.
          [assembly: ComVisible(false)]

          // The following GUID is for the ID of the typelib if this project is exposed to COM
          [assembly: Guid("da9b5517-7c63-4ed2-8f42-e573af1df70b")]

          // Version information for an assembly consists of the following four values:
          //
          //      Major Version
          //      Minor Version 
          //      Build Number
          //      Revision
          //
          [assembly: AssemblyVersion("1.0.0.0")]
          [assembly: AssemblyFileVersion(
          "1.0.0.0")]






          sn –k c:\Version.snk
          





          posted on 2008-09-15 12:14 小高 閱讀(627) 評論(0)  編輯  收藏 所屬分類: Build構建|git版本控制

          導航

          <2008年9月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          統計

          常用鏈接

          留言簿(3)

          隨筆分類(352)

          收藏夾(19)

          關注的blog

          手冊

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 进贤县| 武定县| 盘山县| 耒阳市| 九龙城区| 梧州市| 宣武区| 咸阳市| 柞水县| 承德县| 正镶白旗| 晋州市| 基隆市| 靖边县| 蓬安县| 北海市| 调兵山市| 黑河市| 开阳县| 荣成市| 万安县| 彰化市| 平顶山市| 西丰县| 荣昌县| 铁力市| 巴中市| 东海县| 岳池县| 搜索| 舒兰市| 鹿邑县| 庆阳市| 通许县| 罗城| 高雄县| 晋城| 龙井市| 嵊州市| 渝北区| 淅川县|