July 2015
Intermediate to advanced
1300 pages
87h 27m
English
Reflection also enables you to execute dynamic code, meaning that you can pick up types defined within an assembly, creating instances and invoking types from Visual Basic code without having a reference to that assembly. For example, imagine you want to load the People.dll assembly and create and populate an instance of the Person class, as shown in Listing 44.3.
LISTING 44.3 Creating and Running Dynamic Code
Imports System.ReflectionModule DynamicCode Sub DynCode() Dim asm = Assembly.LoadFrom("People.dll") 'Gets the type definition Dim personType = asm.GetType("People.Person") 'Gets the LastName property definition Dim lastNameProperty As PropertyInfo ...