[Mono-bugs] [Bug 75029][Nor] New - Invoke(obj,
args) fails on static methods if obj is not null
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Mon May 23 07:52:51 EDT 2005
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 sgay at bigorno.net.
http://bugzilla.ximian.com/show_bug.cgi?id=75029
--- shadow/75029 2005-05-23 07:52:51.000000000 -0400
+++ shadow/75029.tmp.21024 2005-05-23 07:52:51.000000000 -0400
@@ -0,0 +1,69 @@
+Bug#: 75029
+Product: Mono: Runtime
+Version: 1.1
+OS: All
+OS Details: Debian testing, probably all
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: sgay at bigorno.net
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Invoke(obj, args) fails on static methods if obj is not null
+
+Description of Problem:
+When calling MethodInfo:Invoke(obj, args) on a static method, with obj
+being not null, an exception is thrown. It works fine on Windows.
+
+Steps to reproduce the problem:
+Compile and run the following code:
+
+using System;
+using System.Reflection;
+
+public class MainClass
+{
+ public static void Main()
+ {
+ Foo foo = new Foo();
+ Type type = foo.GetType();
+ MethodInfo mi = type.GetMethod("DoFoo");
+ object[] args = { 1, 1 };
+ object inst = new Object();
+ object result = mi.Invoke(inst, args);
+ Console.WriteLine("1+1={0}", result);
+ }
+}
+
+public class Foo
+{
+ public static int DoFoo(int x, int y)
+ {
+ return x+y;
+ }
+}
+
+Actual Results:
+Unhandled Exception: System.Reflection.TargetException: Unable to invoke an
+invalid target.
+in <0x00000> <unknown method>
+in (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
+(object,object[])
+in <0x0006f> System.Reflection.MonoMethod:Invoke (System.Object obj,
+BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[]
+parameters, System.Globalization.CultureInfo culture)
+
+Expected Results:
+Console displays: "1+1=2"
+This is what happens on Windows.
+
+How often does this happen?
+Always
+
+Additional Information:
+Detected in FlexWiki. Currently using a workaround using mi.IsStatic.
More information about the mono-bugs
mailing list