HighTechTalks DotNet Forums  

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

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss Re: invoke a method by reflection#,the method's parameters can not be ArrayList? in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Erick
 
Posts: n/a

Default Re: invoke a method by reflection#,the method's parameters can not be ArrayList? - 08-02-2005 , 05:11 AM






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 (AT) sogou (DOT) com> wrote


Quote:
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!


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.