D
De Roeck
Thanks for reading,
I've got the following function:
Private allFlags As BindingFlags = BindingFlags.Public Or
BindingFlags.NonPublic Or _
BindingFlags.Static Or _
BindingFlags.Instance
Public Shared Function StartAUT(ByVal applicationPath As String, ByVal
typeName As String) As Object
Dim aTtype As Type =
Assembly.LoadFrom(applicationPath).GetType(typeName)
Dim obj As Object = Activator.CreateInstance(type1)
aType.GetMethod("Show", allFlags).Invoke(obj, Nothing)
Return obj
End Function
When I give as applicationPath a simple form (afrom.exe) then there
are by default two show-methods
1. show()
2. show(IWin32Window)
The program is giving an execption and complaining that he found two
methods.
I want to invoke the first one, that without parameters.
How can I do that, what do I wrong?
They already told me that I can use follow code to have the same
result:
------
For Each m As MethodInfo In typeUT.GetMethods("Show", allFlags)
If m.GetParameters().Length = 0 Then
mi = m
Exit For
End If
Next
------
I think that the problem is that I don't give the correct "empty"
parameter, and would like to know the sollution in VB.
I found the following C# code with do correctly, but I need it in VB.
C#
------
Assembly asm = Assembly.LoadFrom(applicationPath);
Type typeUT = asm.GetType(typeName);
object obj = Activator.CreateInstance(typeUT);
MethodInfo mi = typeUT.GetMethod("Show", allFlags);
mi.Invoke(obj, null);
Return obj;
I've got the following function:
Private allFlags As BindingFlags = BindingFlags.Public Or
BindingFlags.NonPublic Or _
BindingFlags.Static Or _
BindingFlags.Instance
Public Shared Function StartAUT(ByVal applicationPath As String, ByVal
typeName As String) As Object
Dim aTtype As Type =
Assembly.LoadFrom(applicationPath).GetType(typeName)
Dim obj As Object = Activator.CreateInstance(type1)
aType.GetMethod("Show", allFlags).Invoke(obj, Nothing)
Return obj
End Function
When I give as applicationPath a simple form (afrom.exe) then there
are by default two show-methods
1. show()
2. show(IWin32Window)
The program is giving an execption and complaining that he found two
methods.
I want to invoke the first one, that without parameters.
How can I do that, what do I wrong?
They already told me that I can use follow code to have the same
result:
------
For Each m As MethodInfo In typeUT.GetMethods("Show", allFlags)
If m.GetParameters().Length = 0 Then
mi = m
Exit For
End If
Next
------
I think that the problem is that I don't give the correct "empty"
parameter, and would like to know the sollution in VB.
I found the following C# code with do correctly, but I need it in VB.
C#
------
Assembly asm = Assembly.LoadFrom(applicationPath);
Type typeUT = asm.GetType(typeName);
object obj = Activator.CreateInstance(typeUT);
MethodInfo mi = typeUT.GetMethod("Show", allFlags);
mi.Invoke(obj, null);
Return obj;