Vs 引用第三方DLL文件 版本不一致問題 (npoi與memcached中的ICSharpCode.SharpZipLib版本沖突的解決方案)


最近在 做 MailChimp 與網站功能 集成時,發現 MailChimp 2API 中的 MailChimp.dll  中的依賴項 SerivceStack.Text.dll (版本為3.9.71.0)與我們WebSite 中的 ServiceStack.Text.dll (版本為4.0.0.0)的版本相沖突,當我們 寫了  MailChimpManager mc = new MailChimpManager(ApiKey); 時 提示 無法加載 SerivceStack.Text.dll (版本為3.9.71.0)的程序集異常。

 

我們通過使用 ILMerge 工具把 MailChimp.dll 和 ServiceStack.Text.dll (版本為4.0.0.0)這兩個程序集 合並為 一個 程序集然后進行引用。

命令如下:

C:\Program Files (x86)\Microsoft\ILMerge>ILMerge.exe /target:library /targetplat
form:v4 /out:"D:\MailChimp4.dll" "D:\MailChimp.dll" "D:\ServiceStack.Text.dll" /
wildcards /log:"D:\AandB4.log"

 

1、先下載最新的 ILMerge 工具安裝包:

ILMerge是合並.net的assembly的工具,最新版的支持.net 4.0的ILmerge下載:

http://www.microsoft.com/downloads/details.aspx?FamilyID=22914587-b4ad-4eae-87cf-b14ae6a939b0&displaylang=en

ILMerge用法示例如下:

ILMerge.exe /target:library /targetplatform:v4 /out:"E:\Projects\ILMergeTest\A\Ref\AandB4.dll" "E:\Projects\ILMergeTest\A\A\bin\Debug\*.dll" /wildcards /log:"E:\Projects\ILMergeTest\A\Ref\AandB4.log"

參數說明:

/target:library  =》表示生成目標為dll

/targetplatform:v4  =》 編譯平台為.net4.0

/out:"E:\Projects\ILMergeTest\A\Ref\AandB4.dll"  =》合並后輸出文件路徑

"E:\Projects\ILMergeTest\A\A\bin\Debug\*.dll" /wildcards =》合並的dll,因為此處使用了通配符,因此需要 .wildcards

/log:"E:\Projects\ILMergeTest\A\Ref\AandB4.log" =》輸出合並日志

 

2、相關參考鏈接幫助:

http://stackoverflow.com/questions/8077570/how-to-merge-multiple-assemblies-into-one


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM