Yes There is a way... it involves reflection.
My C# is poor but you should get the Idea....Code:static void Main() { //Application.Run(new Form1()); Application.Run((System.Windows.Forms.Form) CreateInstance("Form2")); } private static System.Object CreateInstance(System.String TypeName) { System.Reflection.Assembly ThisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Type[] MyTypes = ThisAssembly.GetTypes(); for (int i=0; i<MyTypes.Length; i++) { if(String.Compare(MyTypes[i].Name, TypeName) == 0) return System.Activator.CreateInstance(MyTypes[i]); } return null; // Failed }





Reply With Quote