invoke a method by reflection£¬the method's parameters can not be ArrayList?

Discussion in 'ASP .Net' started by jerry051, Aug 1, 2005.

  1. jerry051

    jerry051 Guest

    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!
    jerry051, Aug 1, 2005
    #1
    1. Advertising

  2. jerry051

    Erick Guest

    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" <> wrote in message
    news::

    > 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!
    Erick, Aug 2, 2005
    #2
    1. Advertising

  3. jerry051

    Oliver Sturm Guest

    Re: invoke a method by =?UTF-8?B?cmVmbGVjdGlvbu+/ve+/ve+/ve+/ve+/vQ==?==?UTF-8?B?77+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+9?==?UTF-8?B?77+977+977+977+977+977+977+977+977+977+977+977+977+977+977+977+9?==?UTF-8?B?77+977+977+977+97

    This has been answered in the languages.csharp group.



    Oliver Sturm
    --
    omnibus ex nihilo ducendis sufficit unum
    Spaces inserted to prevent google email destruction:
    MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
    ICQ 27142619 http://www.sturmnet.org/blog
    Oliver Sturm, Aug 2, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. [Gauthier]
    Replies:
    2
    Views:
    14,142
    [Gauthier]
    Dec 3, 2003
  2. Daniel
    Replies:
    0
    Views:
    415
    Daniel
    Mar 12, 2005
  3. imran
    Replies:
    1
    Views:
    17,994
    Thomas Fritsch
    Feb 1, 2005
  4. xz
    Replies:
    16
    Views:
    2,337
  5. Sébastien de Mapias
    Replies:
    11
    Views:
    863
    Roedy Green
    Nov 9, 2009
Loading...

Share This Page