C#中將dll匯入exe,並加殼

來源:互聯網
上載者:User

ILMerge runs in the v2.0 .NET Runtime, but it is also able to merge v1 or v1.1 assemblies. However it can merge PDB files only for v2 assemblies.

Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono.

Download: http://download.microsoft.com/download/1/3/4/1347C99E-9DFB-4252-8F6D-A3129A069F79/ILMerge.msi

因為使用了3層架構,運行目錄下有很多dll檔案,最終發布時,我打算將dll檔案都合并到exe檔案中去。微軟發布的免費軟體ILmerge可以完成這項工作,研究了一下,其用法如下:

1、合并file1.dll、file2.dll到destination.dll
ILmerge /ndebug /target:dll /out:C:\destination.dll /log C:\file1.dll C:\file2.dll

2、合并file1.dll、file2.dll以及myApp.exe到newApp.exe  
ILmerge /ndebug /target:winexe /out:C:\newApp.exe /log C:\myapp.exe C:\file1.dll C:\file2.dll

注意:合并為exe時,myapp.exe必須寫在file1.dll、file2.dll前面

完 成之後,就得到了一個exe檔案,如果想做一些邪惡的事情,可以將一些破解軟體的dll合并到你的exe中去。前提是,所有的dll都是託管的,如果嘗試 合并C++寫的dll,則會失敗。有一個工具,叫做mergebin.exe,可以合并託管和非託管dll,用法我還沒研究出來,似乎比較困難的樣子。這 個工具是ADO.NET 2.0 Data Provider for SQLite的作者寫的,他發布的System.Data.SQLite.dll可以被dotNet程式引用,還可以直接被C/C++程式調用,這個 dll就是託管和非託管混合的dll,果然是很牛的!mergebin.exe在其源碼包裡,有興趣的朋友可以研究一下。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.