[Mono-list] Reflection bug or I am wrong ...

Yury Serdyuk Yury@serdyuk.botik.ru
Mon, 11 Nov 2002 17:54:40 +0300


Hi !
I have problem in such situation .
I have file  A.cs  wth classe  A and C :

> using  System;
> public  class   C   {
>  int   p;
>  public  C  ( int p )  {
>   this.p = p;
>  }
>  public int  getP()  {  return ( p ); }
> }
> //////////////////////////////////////////////
> class  A  {
>  public static void  Main ( string[]  args ) {
>   Console.WriteLine ( "Test" );
>  }
>  public void f ( C   c )  {
>   Console.WriteLine ( "p = {0}", c.getP() );
>  }
> }

and file  DInvoke2.cs :

> using  System;
> using  System.Reflection;
> public  class  C  {
>  int    p;
>  public  C  ( int p )  {
>   this.p = p;
>  }
>  public int getP() { return ( p ); }
> }
> //////////////////////////////////////////////
> class  DInvoke2  {
>  public static void  Main ( string[]  args ) {
>   Assembly  asm      = Assembly.LoadFrom ( "A.exe" );
>   Type      Aclass   = asm.GetType ( "A" );
>   MethodInfo fMethod = Aclass.GetMethod ( "f" );
>   object    Aobj     = Activator.CreateInstance ( Aclass );
>   Console.WriteLine ( "... Dynamically Invoking" );
>   object[]  argobjs = new object [ 1 ];
>   argobjs [ 0 ] = new C ( 1000 );
>   fMethod.Invoke ( Aobj,
>                              argobjs  );
>  }
> }

but after invoking the  function   f
I have received  a Reflection.Invoke  ArgumentException .
I have using  Mono Release 0.16 under RedHat.

YS.