开发者

how do i force a DLL to be built with the exe so there is only one file?

i have a simple app in c#. i would like the DLL to be "inside" the exe f开发者_Python百科ile. how do i do this?


ILMerge does exactly what you are looking for


the page is a little misleading, ILMerge works on V3 and V4 assemblies per its actual webpage

ILMerge should work just fine with newer versions of .NET. Just use the option: /targetplatform:v4,. For version 3.5, you probably don't need to set the target platform, but you may need to add the v3.5 framework directory as a /lib option so that assemblies from there can be found. (Unless they're in the GAC in which case they'll be found anyway.) To run ILMerge in the v4.0 runtime, use this config file.


To answer how do you use it from your question in the other answer

Usage: ilmerge [/lib:directory]* [/log[:filename]] [/keyfile:filename [/delaysign]] [/internalize[:filename]] [/t[arget] :(library|exe|winexe)] [/closed] [/ndebug] [/ver:version] [/copyattrs [/allowMultiple]] [/xmldocs] [/attr:filename] [/ta rgetplatform:[,] | /v1 | /v1.1 | /v2 | /v4] [/useFullPublicKeyForReferences] [/wildcards] [/zeroPe Kind] [/allowDup:type]* [/union] [/align:n] /out:filename [...]

So ilmerge /out:Combined.exe mainFile.exe otherDll.dll for your case as most of the defaults should be fine


ILMerge can do this for .NET assemblies - though it has some limitations with certain types of assemblies (such as WPF Assemblies).

You can, alternatively, use the assembly as a resource and load it on demand, or use one of the many commercial obfuscators which support assembly merging. Many of the third party options support more elaborate depedency merging and/or dependency embedding. A good example of this is SmartAssembly, which supports both options.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜