Search code examples
c#dllilmerge

Embedded a DLL into the exe through ILMerge, I can't access the dll


Problem: I embedded a DLL into the exe through ILMerge, but this dll has no dependency relationship with the exe. Now I want to find the dll in the exe, what do I need to do?
Details:
I embedded all resources into the DLL, all logic code is EXE. I don't want to compile exe again, only modify the resource dll to change the exe's skin.
Then , I meet the problem.


Solution

    1. To find the DLL in the EXE using the EXE code, use reflection on the EXE's assembly and look for the DLL's entry point class.

    2. To not compile the EXE again when merging a different DLL, keep the original EXE around and when the DLL changes, ilmerge the changed DLL instead (carefully still keeping the original EXE around). Note that ILMerging the changed DLL into the EXE the original DLL was merged into almost works but not quite.