Reputation: 9966
How can I programmatically add an assembly (DLL) as reference in a C# project? I need to add a reference at run time.
Consider if my project uses another class library (DLL) then I need to add that DLL as a reference in my project. How can I do that at run time?
Upvotes: 1
Views: 656
Reputation: 52501
Probably you want to get the type information from a class in another .dll, and then create an object instance of that class.
var lateBindingType = Type.GetType("Name.Of.The.Class,NameOfDll");
var instance = Activator.CreateInstance(lateBindingType);
In the call to Type.GetType you use the Fully Qualified Type Name.
Upvotes: 1
Reputation: 52300
I guess you want to load an type at runtime? You can use Assembly.Load and reflection to do this.
Upvotes: 2