Re: invoke a method by reflection#,the method's parameters can not be ArrayList?



Here is your problem, the Invoke method overload you're using takes the target object and an array or arguments. In your case you only have one argument which is a object array.

Change:
object temp = myType.GetMethod("Exec").Invoke(myInstance, obj);	

To:
object temp = myType.GetMethod("Exec").Invoke(myInstance,new object[]{ obj});



HTH Erick Sgarbi www.blog.csharpbox.com



"jerry051" <bestsoft@xxxxxxxxx> wrote in message news:OI7p2AolFHA.3816@xxxxxxxxxxxxxxxxxxxx:

I invoke a method by reflection, when this method's parameters is simple
type like int or string,the invoking is correct and secceed. But when the
parameters is ArrayList type, debuger tips me that meet
System.Reflection.TargetParameterCountException error, and parameters count
is not matching. please help me why happen this error,thanks a lot!

.



Relevant Pages

  • Re: Redimensioning an Array
    ... You can use the ArrayList type in the System.Collections namespace to ... kind of functionality, arrays lengths are immutable once created). ... >I found an article that discussed dynamic allocation of an array but it ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Array and ArrayList
    ... In internal storage for an ArrayList is simply an array of objects ... > An ArrayList type is roughly equivalent to the LinkedList learned about in ... >> Thanks alot for any help ...
    (microsoft.public.dotnet.languages.csharp)

Loading