If you want to dynamically want to load a form and you only know the classname then the following snippet may be of use:
Type t = Type.GetType("ConsoleApplication1.Form1");if (t != null){ System.Windows.Forms.Form f = (System.Windows.Forms.Form) Activator.CreateInstance(t); f.ShowDialog();}
Now, if you'd want to load the form from a different assembly, let's say, some library assembly with forms, then you need to specifiy an AssemblyQualifiedName.
Like:
Type t = Type.GetType("ClassLibrary1.Form1, ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");if (t != null){ System.Windows.Forms.Form f = (System.Windows.Forms.Form)Activator.CreateInstance(t); f.ShowDialog();}
This will dynamically load the form and show it. So no compiletime binding needs to be done.