There are a lot of posts on the web about single file packaging, although it can expand the thinking, quality is general.
Here is the simplest one.
First, add DLLs to your project and change their build action to embedded resources.
Second, referring to the solution given by the CLR Via C #, add a few lines of code, as follows:
1. Add an assembly to load the failed event first.
// To add an Assembly resolution event AppDomain.CurrentDomain.AssemblyResolve + = (sender, args) = LoadFromResource (args. Name);
2. Load the assembly (DLL) according to the file name.
/// <summary>///The corresponding assembly is loaded according to the name of the resource item to be loaded. /// </summary>/// <param name= "Argsname" >The name of the item to resolve. </param>/// <returns>returns the assembly for the corresponding item. </returns>PrivateAssembly LoadFromResource (stringargsname) { stringDllName =NewAssemblyName (Argsname). Name +". DLL"; varAssem =assembly.getexecutingassembly (); varResourceName = Assem. GetManifestResourceNames (). FirstOrDefault (rn =RN. EndsWith (DllName)); if(resourcename = =NULL)return NULL;//The assembly was not found. using(Stream stream =Assem. GetManifestResourceStream (resourcename)) {byte[] Assemblydata =New byte[Stream. Length]; Stream. Read (Assemblydata,0, assemblydata.length); returnAssembly.Load (Assemblydata); }}
Finish.
C # Single File application