"Append a DLL" is nothing but absurd. You can always load an assembly (assembly, not "DLL") using Reflection:
https://msdn.microsoft.com/en-us/library/system.reflection.assembly%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/1009fa28(v=vs.110).aspx[
^],
https://msdn.microsoft.com/en-us/library/ky3942xh(v=vs.110).aspx[
^]… see all other
Assembly.Load*
methods.
Then you can use
Assembly.LoadTypes
or other similar method to get types:
https://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettypes(v=vs.110).aspx[
^].
With the type, you can get the members you need and, in particular, constructors; then you can instantiate any type using
System.Reflection.ConstructorInfo
:
https://msdn.microsoft.com/en-us/library/system.reflection.constructorinfo%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.reflection.constructorinfo.invoke%28v=vs.110%29.aspx[
^].
And then do whatever you want.
It would be the best to base getting the the type you need by using some declarations used by both host and loaded assemblies. One of the best option is to find the type by the interface it is supposed to implement. For further detail, please see my past answers:
Gathering types from assemblies by it's string representation[
^],
Access a custom object that resides in plug in dll[
^].
Note that the assembly loaded during runtime is not the part of your project, otherwise doing it dynamically would not make any sense at all; you could simply reference the assembly and use it in a usual way. Dynamically, you load assembly either using the file name of the assemblies main
module (the one with .NET assembly manifest) or from GAC by its
strong name.
—SA