I have my project in C# and a .dll also in C#. I have seen it is possible to include the dll and extract the .dll from the exe at runtime in other languages.
How would i achieve this in C#?
I have my project in C# and a .dll also in C#. I have seen it is possible to include the dll and extract the .dll from the exe at runtime in other languages.
How would i achieve this in C#?
You can embed an assembly as a resource file inside another assembly (just go to project properties and open the resource section).
Next, you can retrieve the resource file at runtime into a stream, by using Assembly.GetManifestResourceStream()
.
Finally, you can load your assembly in the current application domain or in a separate application domain with Assembly.Load(byte\[\])
(by loading the resource stream into a byte array).
So you can load your resource assembly from memory directly, without having to save it to disk first.
You can now load types from the assembly, with one of the Assembly.GetType
overloads. Of course, you may want to define some contracts between the main assembly and your resource assembly, so you can make use of the custom types inside this assembly.