[Mono-bugs] [Bug 72830][Wis] New - Reflection/Generics: Error invoking a method of a generic type (argument is generic type)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 21 Feb 2005 19:39:47 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by spigaz@gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=72830

--- shadow/72830	2005-02-21 19:39:47.000000000 -0500
+++ shadow/72830.tmp.29735	2005-02-21 19:39:47.000000000 -0500
@@ -0,0 +1,85 @@
+Bug#: 72830
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: Gentoo 2.6.10
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: spigaz@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Reflection/Generics: Error invoking a method of a generic type (argument is generic type)
+
+Description of Problem:
+Error when using reflection to invoke a method of a generic type with a
+generic type argument.
+
+Steps to reproduce the problem:
+1. Insert into a file:
+
+using System;
+using System.Reflection;
+
+namespace FLMID.Bugs.ParametersOne
+{
+	public class Class<T>
+	{
+		public void Add(T x)
+		{
+			System.Console.WriteLine("OK");
+		}
+	}
+	public class Test
+	{
+	
+		public static void Main(string [] args)
+		{
+			Class<string> instance = new Class<string>();
+			
+			MethodInfo _method = null;
+			
+			foreach(MethodInfo method in
+typeof(Class<string>).GetMethods(BindingFlags.Instance | BindingFlags.Public))
+			{
+				if(method.Name.Equals("Add") && method.GetParameters().Length==1)
+				{
+					_method = method;
+					break;
+				}
+			}
+			_method.Invoke(instance , new object[]{"1"});
+		}
+	}
+}
+
+2. Compile it normally with gmcs.
+3. Run it without any args.
+
+Actual Results:
+Unhandled Exception: System.Reflection.TargetException: Unable to invoke an
+invalid target.
+in <unknown method>
+in <0x00004> System.Reflection.MonoMethod:InternalInvoke (System.Object ,
+System.Object[] )
+in [0x00033] (at
+/software/mono/mono.2005.02.21/mcs/class/corlib/System.Reflection/MonoMethod.cs:121)
+System.Reflection.MonoMethod:Invoke (System.Object obj, BindingFlags
+invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
+System.Globalization.CultureInfo culture)
+
+
+Expected Results:
+OK
+
+How often does this happen? 
+Always
+
+Additional Information:
+Tested in .NET 2.0 and worked fine, the .NET 2.0 assembly gives the same
+error on mono.