發表文章

目前顯示的是 9月, 2013的文章

組件繫結重新導向功能測試

  在開發多個專案下,共用的功能大部份都會寫在共用的函式庫內,而在函式庫引用的外部組件 如:iTextSharp、NPOI等,若與其他專案上的版本不一致的話,會造成 AP無法執行,在不想讓現有的專案再去重新參考較新或較舊的組件的話,可以考慮使用BindingRedirect來解決。 測試案例:AP與Lib各自參考iTextSharp Case 1: AP參考版本較低、Lib參考版本較高 執行結果:在AP使用Lib的方法會出現找不到版本較高的組件 解決方法:在組態使用bindingRedirect讓實際執行是較 低的版本   < runtime >   < assemblyBinding   appliesTo = " v2.0.50727 "   xmlns = " urn:schemas-microsoft-com:asm.v1 " > < dependentAssembly >      < assemblyIdentity   name = " itextsharp "   publicKeyToken = " 8354ae6d2174ddca " />   < bindingRedirect   oldVersion = " 5.4. 4 .0 "   newVersion = " 5.4. 0 .0 " />      </ dependentAssembly > </ assemblyBinding > </ runtime > Case 2: AP 參考 版本較高、Lib 參考 版本較低 執行結果: 在AP 使用Lib的方法會出現找不到版本較低的組件 解決方法:在組態使用bindingRedirect讓實際執行是較 高 的版本 < runtime >   < assemblyBinding   appliesTo = " v2.0.50727 "   xmlns = " urn:schemas-microsoft-com:asm.v1 " >     < dep