invoked.
But I C#-sharp code it's executed perfectly. So, i should think that
<bphillips@nospam.crowechizek.com.spammenot> wrote:
>How about just finding the member based on the number of parameters?
>
>Dim asm As System.Reflection.Assembly =
>System.Reflection.Assembly.LoadFrom(applicationPath)
>Dim typeUT As Type = asm.GetType(typeName)
>Dim obj As Object = Activator.CreateInstance(typeUT)
>Dim mi As MethodInfo = Nothing
>
>For Each m As MethodInfo In typeUT.GetMethods("Show", allFlags)
> If m.GetParameters().Length = 0 Then
> mi = m
> Exit For
> End If
>Next
>
>mi.Invoke(obj, Nothing)
>
>Bryan Phillips
>MCSD, MCDBA, MCSE
>Blog:
http://bphillips76.spaces.live.com >
>
>
>
>"De Roeck" <email_me@mobistarmail.be> wrote in message
>news:cl2ak2h0256dd5r1dvcpsqn37rcm0hpn4n@4ax.com:
>
>> I've futher analysed the differences and found with Reflector that
>> there are indeed two Show-methods
>>
>> Public Sub Show()
>> Public Sub Show(ByVal owner As IWin32Window)
>>
>> I want to invoke the first one, that without paramaters
>> so I use:
>>
>> VB.NET
>> -------
>> Dim asm As System.Reflection.Assembly =
>> System.Reflection.Assembly.LoadFrom(applicationPath)
>> Dim typeUT As Type = asm.GetType(typeName)
>> Dim obj As Object = Activator.CreateInstance(typeUT)
>> Dim mi As MethodInfo = typeUT.GetMethod("Show", allFlags)
>> mi.Invoke(obj, Nothing)
>> ------
>>
>> But he also invoke the second method (of show).
>>
>> when I run the same in C# then he only invokes that one without
>> paramters:
>>
>> 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);
>> ------
>>
>> How to tell VB that he has to invoke only those without parameters?
>>
>> On Sun, 29 Oct 2006 16:22:54 +0000, "Bryan Phillips"
>> <bphillips@nospam.crowechizek.com.spammenot> wrote:
>>
>>
>> >Do you have Option Strict turned on for VB?
>> >
>> >Bryan Phillips
>> >MCSD, MCDBA, MCSE
>> >Blog:
http://bphillips76.spaces.live.com >> >
>> >
>> >
>> >
>> >"De Roeck" <email_me@mobistarmail.be> wrote in message
>> >news:1fg9k2lv9t2honp6hsm1rmteskn21eup79@4ax.com:
>> >
>>
>> >> I want to launch an application by reflection and get his handle
>> >> back.
>> >>
>> >> But when I run this code in C# then it's handled correctly.
>> >> The application(-path) is started on a new thread and obj is the hwnd
>> >> of the started application.
>> >>
>> >> private static BindingFlags allFlags = BindingFlags.Public |
>> >> BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
>> >>
>> >> public static object StartAUT(string applicationPath, string typeName)
>> >> {
>> >> try
>> >> {
>> >> 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;
>> >> }
>> >> catch{}
>> >> return null;
>> >> }
>> >>
>> >> but when I launch the same code in VB.NET than I received an
>> >> AmbiguousMatchException execption.
>> >>
>> >>
>> >> Private Shared 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
>> >> Try
>> >> Dim asm As System.Reflection.Assembly =
>> >> System.Reflection.Assembly.LoadFrom(applicationPath)
>> >> Dim typeUT As Type = asm.GetType(typeName)
>> >> Dim obj As Object = Activator.CreateInstance(typeUT)
>> >> Dim mi As MethodInfo = typeUT.GetMethod("Show", allFlags)
>> >> mi.Invoke(obj, Nothing)
>> >> Return obj
>> >> Catch
>> >> End Try
>> >> Return Nothing
>> >> End Function
>> >>
>> >>
>> >> What do I wrong?
>> >>
>> >> Greetings,