Interviews3 answers
How do I dynamically load a control from a DLL?
3 Answers
You use System Reflection to dynamically load a control. If the DLL is named "SpecControls.DLL" and the class you want is "SpecControls.ColorControl", then use this code.
// load the assembly
System.Reflection.Assembly assembly = Assembly.LoadFrom("SpecControls.DLL");
// get the type
Type t = assembly.GetType("SpecControls.ColorControl");
Control c = (Control)Activator.CreateInstance(t);
parent.Controls.Add(c);
Sai KrishnaPosted Dec 14, 2018, 5:19 PM EST
You use System Reflection to dynamically load a control. If the DLL is named "SpecControls.DLL" and the class you want is "SpecControls.ColorControl", then use this code.
// load the assembly
System.Reflection.Assembly assembly = Assembly.LoadFrom("SpecControls.DLL");
// get the type
Type t = assembly.GetType("SpecControls.ColorControl");
// create an instance and add it.
//
Control c = (Control)Activator.CreateInstance(t);
parent.Controls.Add(c);
Sai KrishnaPosted Dec 14, 2018, 5:18 PM EST
http://social.msdn.microsoft.com/Forums/vstudio/en-US/939afd00-18fd-4ea5-92f1-ec343876b801/dynamically-load-user-controls-from-a-dll-file-in-c-net?forum=csharpgeneral
Munesh SharmaPosted Apr 23, 2014, 1:19 AM EDT


