How to package all the DLL files into an EXE and run it for the customer? (Transfer)
Generally, write a winformProgramMultiple DLL files are referenced. If you publish this winform, there will be many DLL files in a directory.
What should I do if I want to just upload a client.exe?
It is easy to package the DLL into the EXE as a resource.
Then the question is how you can load these DLL files at runtime.
One feasible method is to load all the DLL files at a time when the program is running, and then load it with appdomain. Load.
However, a bad thing is that the startup speed is too slow.
Appdomain provides an event called assemblyresolve, which tells you that DOTNET cannot find the Assembly it is looking.
By associating this event, compare whether resolveeventargs. Name is the one you packed, and then load the DLL as needed.
For example, download resofdll.zip
Of course, if you develop DLL and reference others' DLL, you can also do this. However, you must ensure that the assemblyresolve event is associated before using other DLL classes. (This can be executed in the static constructor of all classes that use other DLL classes.CodeTo ensure this condition)