[Mono-list] GetMethodFromHandle and NotImplementedException
Carlos Ble
ble.jurado at gmail.com
Fri Jul 20 04:30:45 EDT 2007
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/dda64708/attachment-0001.html
More information about the Mono-list
mailing list