I have a ListBox that is populated with my entity names, i.e. A1AllocationHelp1Entity
I need to pass that string name and get the EntityBase2 type.
I can get it using reflection:
Public Function CreateEntity(ByVal entityName As String) As EntityBase2
Dim dynamicAssembly As Assembly = Assembly.LoadFrom(DALFileName)
Dim assemblyName As String = Split(dynamicAssembly.FullName, ",")(0)
Dim sEntityName As String = assemblyName & ".EntityClasses." & entityName
Dim handle As ObjectHandle = Activator.CreateInstance(assemblyName, sEntityName)
Dim entity As EntityBase2 = CType(handle.Unwrap(), EntityBase2)
Return entity
End Function
but if I have the types there I would like to be able to instantiate it somehow.
How can I do that?