[Mono-bugs] [Bug 81501][Wis] New - ConstructorInfo.Invoke incorrectly throws System.MethodAccessException: Cannot invoke constructor of an abstract class.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue May 1 02:01:40 EDT 2007


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 jeroen at sumatra.nl.

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

--- shadow/81501	2007-05-01 02:01:40.000000000 -0400
+++ shadow/81501.tmp.29049	2007-05-01 02:01:40.000000000 -0400
@@ -0,0 +1,49 @@
+Bug#: 81501
+Product: Mono: Runtime
+Version: 1.2
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: jeroen at sumatra.nl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ConstructorInfo.Invoke incorrectly throws System.MethodAccessException: Cannot invoke constructor of an abstract class.
+
+On Mono 1.2.3.1 the following code incorrectly throws an exception:
+
+using System;
+using System.Reflection;
+
+abstract class Base
+{
+}
+
+class Program : Base
+{
+	public static void Main(string[] args)
+	{
+		object obj = 
+System.Runtime.Serialization.FormatterServices.GetUninitializedObject
+(typeof(Program));
+		typeof(Base).GetConstructor(BindingFlags.Instance | 
+BindingFlags.NonPublic, null, Type.EmptyTypes, null).Invoke(obj, new 
+object[0]);
+	}
+}
+
+Actual result:
+Unhandled Exception: System.Reflection.TargetInvocationException: 
+Exception has been thrown by the target of an invocation. ---> 
+System.MethodAccessException: Cannot invoke constructor of an abstract 
+class.
+
+Expected result:
+no exception (it is legal to call the constructor on an abstract type, if 
+the instance passed in a non-abstract subtype).


More information about the mono-bugs mailing list