Embedding DLLs in a compiled executable

前端 未结 16 2676
情深已故
情深已故 2020-11-21 07:07

Is it possible to embed a pre-existing DLL into a compiled C# executable (so that you only have one file to distribute)? If it is possible, how would one go about doing it?<

16条回答
  •  不知归路
    2020-11-21 07:50

    Yes, it is possible to merge .NET executables with libraries. There are multiple tools available to get the job done:

    • ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly.
    • Mono mkbundle, packages an exe and all assemblies with libmono into a single binary package.
    • IL-Repack is a FLOSS alterantive to ILMerge, with some additional features.

    In addition this can be combined with the Mono Linker, which does remove unused code and therefor makes the resulting assembly smaller.

    Another possibility is to use .NETZ, which does not only allow compressing of an assembly, but also can pack the dlls straight into the exe. The difference to the above mentioned solutions is that .NETZ does not merge them, they stay separate assemblies but are packed into one package.

    .NETZ is a open source tool that compresses and packs the Microsoft .NET Framework executable (EXE, DLL) files in order to make them smaller.

提交回复
热议问题