Re: Execute code at runtime
Quote:
Does VB.net allow for a way of executing a string of code at runtime?
Basically i'm trying to grab a form name from a database and display the form.
Sure!
You can do this using Reflection.
It does not compile a thing, just retrieve informations about objects and methods into assemblies and let you call them at runtime.
Take a look to this example:
VB Code:
Assembly a = Assembly.Load(strMyAssemblyFile);
Type oType = a.GetType(strCompleteNamespaceAndClassName);
object oMyObj = Activator.CreateInstance(oType);
MethodInfo oMethod = oType.GetMethod(strMethodName);
oMethod.Invoke(oMyObj, new object[] {MyParam});
Bye!