please help me on creating a user control object in runtime using createobject function or whatever better function in vb.net.
here is my code:
Dim b As New Security.Sec_Role
b.Name = "Sec_Role"
b.visible = true
but i want to use this code:
dim b as object
b = createobject("Security.Sec_Role")
but it always return an error:
Cannot create ActiveX component.
EDIT: i figure it out..thanks a lot..i use this codes:
Dim asm As System.Reflection.Assembly = Assembly.Load("Security")
Dim b As Object = Activator.CreateInstance(asm.GetType("Security.Sec_Role"))
If it is an .Net UserControl you will not be able to use
CreateObjectunless it has been exposed as a Com object according to the MSDN page for CreateObject. Using New would be the proper way to create a .Net UserControl.From above link:
From this MSDN Forum try something like this using
System.Activator.CreateInstance: