Dynamic windows form loading

Is there a way to dynamically load a windows for based on a value from a database query   I want to use late binding instead of a big case statement to load the window.

Thanx,



Robert Beaubien
President
Kool Software


Answer this question

Dynamic windows form loading

  • Bi#

    Of course, you can do that.  However, you need know the Full class name and what assembly implements that class through your database.  You can load the assemlby (System.Reflection.Assembly), if the assmembly is in GAC, and you have the full name of it, or you have a path.   You can call Assembly.GetType to get the type, and call System.Activator.CreateInstance to create an instance of the type.

    However, you need aware if someone could access the database, your code could load some code he wants. It could be a security problem in your app.  You might want to do some checks, or add limitations to prevent this.

    Thanks
    Lifeng

  • Dynamic windows form loading