[Mono-bugs] [Bug 72831][Nor] 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:53 -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=72831

--- shadow/72831	2005-02-21 19:39:53.000000000 -0500
+++ shadow/72831.tmp.29751	2005-02-21 19:39:53.000000000 -0500
@@ -0,0 +1,85 @@
+Bug#: 72831
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: Gentoo 2.6.10
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+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.