[Mono-bugs] [Bug 36109][Nor] New - Activator.CreateInstance returns null

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
26 Dec 2002 05:36:05 -0000


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 mathpup@mylinuxisp.com.

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

--- shadow/36109	Thu Dec 26 00:36:05 2002
+++ shadow/36109.tmp.31069	Thu Dec 26 00:36:05 2002
@@ -0,0 +1,60 @@
+Bug#: 36109
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mathpup@mylinuxisp.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Activator.CreateInstance returns null
+
+Description of Problem: 
+ 
+By default, Activator.CreateInstance() only searches for public constructors. If 
+CreateInstance( Type type, object[] args ) is called, and the only matching 
+constructor is internal, Mono should throw a MissingMethodException. Instead, Mono 
+currently returns null. 
+ 
+Steps to reproduce the problem: 
+1. Compile the attached program activator2.cs 
+2. Run the program 
+3.  
+ 
+ 
+Actual Results: 
+ 
+Program prints "NULL" 
+ 
+ 
+Expected Results: 
+ 
+Unhandled Exception: System.MissingMethodException: Constructor on type MyClass 
+not found. 
+   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder 
+binder, Object[] args, CultureInfo culture, Object[] activationAttributes) 
+   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder 
+binder, Object[] args, CultureInfo culture, Object[] activationAttributes) 
+   at System.Activator.CreateInstance(Type type, Object[] args) 
+   at Testing.Main() 
+ 
+ 
+How often does this happen?  
+ 
+Always 
+ 
+ 
+Additional Information: 
+ 
+This bug might seem very minor, but it can lead to some bugs that very difficult to 
+track down. In our case, in Qt#, we were getting unexpected null reference 
+exceptions, and we finally tracked it down to the Activator.CreateInstance() method. 
+Since the documentation indicates the method either succeeds or throws one of the 
+listed exceptions, we weren't expecting that CreateInstance might be returning null.