[Mono-list] GetMethodFromHandle and NotImplementedException

Gert Driesen gert.driesen at telenet.be
Fri Jul 20 12:44:31 EDT 2007


Hi Carlos,
 
This was recently implemented, and is now working fine on Mono.
 
Gert

  _____  

From: mono-list-bounces at lists.ximian.com
[mailto:mono-list-bounces at lists.ximian.com] On Behalf Of Carlos Ble
Sent: vrijdag 20 juli 2007 14:37
To: Mono-list at lists.ximian.com
Subject: Re: [Mono-list] GetMethodFromHandle and NotImplementedException


Sorry there was an error in the code before.
This is the right Main method (working on .Net):
 
public

static void Main(string [] args) 

{

Console.WriteLine("Hello World!"); 

TestClass<int> test = new TestClass<int>(); 

RuntimeMethodHandle methodHandle =
test.GetType().GetProperty("MyList").GetGetMethod().MethodHandle; 

MethodBase methodBase = MethodInfo.GetMethodFromHandle(methodHandle,
typeof(TestClass<int>).TypeHandle); 

List<int> list = (List< int>)methodBase.Invoke(test, null); 

Console.WriteLine(list.Count); 

}

Cheers


 
2007/7/20, Carlos Ble <ble.jurado at gmail.com>: 

Hi, the sample bellow throwns the NotImplementedException:
 
using System;
using System.Reflection;
using System.Collections.Generic;

namespace test1
{
    public class TestClass<T>
    {
        private List<T> _myList = new List<T>(); 
        
        public List<T> MyList
        {
            get
            {
                return _myList;
            }
                
        }
    }
    
    class MainClass 
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            
            TestClass<int> test = new TestClass<int>();
            RuntimeMethodHandle methodHandle =
test.GetType().GetProperty("MyList").GetGetMethod().MethodHandle;
            RuntimeTypeHandle typeHandle = typeof(int).TypeHandle;
            MethodBase methodBase =
MethodInfo.GetMethodFromHandle(methodHandle, typeHandle);
            List<int> list = (List<int>)methodBase.Invoke(test, null);
            Console.WriteLine(list.Count);
        }
    }
} 

 
2007/7/19, Miguel de Icaza <miguel at novell.com>: 



> I'm getting a NotImplementedException when trying to us
> GetMethodFromHandle for generics: 
>        * System.Reflection.MethodBase.GetMethodFromHandle
> (RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
> However if I use the non-generic version of the method it works with
> generic types :-) 
> Will it be implemented soon ?

Please post samples.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070720/9544dae8/attachment.html 


More information about the Mono-list mailing list