jvcoach23 Posted June 27, 2008 Posted June 27, 2008 i do early binding for everything so far. I now have a need to do latebinding (i think). I'm have a log file that i use to record changes made in a vb app. It uses reflection (think that the right term) where i pass in an object and it takes the object and creates a single string out of the properties in that table, there is a column where i store the object name. Now i'd like to take that object name and query against it using my class structure. So, say i have a class named ClassIndex with property names like tblClassIndexID, ClassName, ClassTitle if i query my table and bring back a certain row, i look and see that the class name was ClassIndex. in early binding i'd do dim oClassIndex as new ClassIndex how do i do this using late binding. hope that is clear enough thanks shannon Quote JvCoach23 VB.Net newbie MS Sql Vet
Leaders snarfblam Posted June 27, 2008 Leaders Posted June 27, 2008 First you need to get the System.Type object that represents the class' type. Then you can either use the Activator class to create objects, or you can use reflection on the System.Type object to get a constructor (or a MethodInfo object, to be more precise) and call that to create the object (you may also be able to use the InvokeMethod function of the System.Type object). Note that unless you are dealing with parameterless constructors things are going to get very tricky very fast. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.