3
Reply

How do I dynamically load a control from a DLL?

Rohit Kumar

Rohit Kumar

11y
7.1k
0
Reply

    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 assemblySystem.Reflection.Assembly assembly = Assembly.LoadFrom("SpecControls.DLL");// get the typeType t = assembly.GetType("SpecControls.ColorControl");Control c = (Control)Activator.CreateInstance(t);parent.Controls.Add(c);

    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 assemblySystem.Reflection.Assembly assembly = Assembly.LoadFrom("SpecControls.DLL");// get the typeType t = assembly.GetType("SpecControls.ColorControl");// create an instance and add it.//Control c = (Control)Activator.CreateInstance(t);parent.Controls.Add(c);

    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