Hi.
I'm trying to do something I don't know if it's possible...
I need to access objects declared on an assembly (class2) from the main class (class1), at runtime, but the only link between them its an Interface.
So I don't really know what objects exist on the 'class2'.
The class2 implements the Interface.
The Interface have 1 method:
- Public function GetObject(name as string) as object
The implementation of this Interface on class2 goes like the following:
So, calling the GetObject function, I can retrieve the FieldInfo of a field inside a class, by reflection, by its name.
The problem is that I don't what the field info... I want the actual object.
On the NEW of the class2 I instanciate several objects.
If class2 were referenced normally, intellisense would just give me the objects, but thru the interface I can't have them that way.
I can use the Assembly.CreateInstance but this will create another instance of the same object, not the already created instance on class2.
So, is there a way to do this?
Thanks,
Alex
I'm trying to do something I don't know if it's possible...
I need to access objects declared on an assembly (class2) from the main class (class1), at runtime, but the only link between them its an Interface.
So I don't really know what objects exist on the 'class2'.
The class2 implements the Interface.
The Interface have 1 method:
- Public function GetObject(name as string) as object
The implementation of this Interface on class2 goes like the following:
Visual Basic:
For Each obj As Object In Me.GetType.GetFields
If TypeOf obj Is System.Reflection.FieldInfo Then
If CType(obj, System.Reflection.FieldInfo).Name = "t" & name Then
'Found the FieldInfo
End If
End If
Next
So, calling the GetObject function, I can retrieve the FieldInfo of a field inside a class, by reflection, by its name.
The problem is that I don't what the field info... I want the actual object.
On the NEW of the class2 I instanciate several objects.
If class2 were referenced normally, intellisense would just give me the objects, but thru the interface I can't have them that way.
I can use the Assembly.CreateInstance but this will create another instance of the same object, not the already created instance on class2.
So, is there a way to do this?
Thanks,
Alex