[Mono-bugs] [Bug 53898][Blo] New - System.ComponentModel.AttributeCollection:GetDefaultAttribute throws MissingMethodException
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 4 Feb 2004 18:22:13 -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 jonwagner@hotmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=53898
--- shadow/53898 2004-02-04 18:22:13.000000000 -0500
+++ shadow/53898.tmp.18277 2004-02-04 18:22:13.000000000 -0500
@@ -0,0 +1,96 @@
+Bug#: 53898
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity: Unknown
+Priority: Blocker
+Component: System
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: jonwagner@hotmail.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: System.ComponentModel.AttributeCollection:GetDefaultAttribute throws MissingMethodException
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+
+System.ComponentModel.AttributeCollection:GetDefaultAttribute throws an
+System.MissingMethodException. Stack trace follows.
+
+
+Steps to reproduce the problem:
+1. Not exactly sure - but I have custom validators in an aspx file.
+During page render, the exception below is thrown.
+
+Actual Results:
+System.MissingMethodException: Default constructor not foundin <0x00144>
+System.Activator:CreateInstance (System.Type,bool)in <0x00012>
+System.Activator:CreateInstance (System.Type)in <0x00046>
+System.ComponentModel.AttributeCollection:GetDefaultAttribute
+(System.Type)in <0x00129>
+System.ComponentModel.AttributeCollection:get_Item (System.Type)in
+<0x00039> System.Web.UI.WebControls.BaseValidator:GetValidationProperty
+(object)in <0x00082>
+System.Web.UI.WebControls.BaseValidator:CheckControlValidationProperty
+(string,string)in <0x00093>
+System.Web.UI.WebControls.BaseValidator:ControlPropertiesValid ()in
+<0x00021> System.Web.UI.WebControls.BaseValidator:get_PropertiesValid ()
+in <0x0009a> System.Web.UI.WebControls.BaseValidator:Render
+(System.Web.UI.HtmlTextWriter)in <0x0001c>
+System.Web.UI.Control:RenderControl (System.Web.UI.HtmlTextWriter)in
+<0x00209> ASP.Logon_ascx:__Render_LogonPane
+(System.Web.UI.HtmlTextWriter,System.Web.UI.Control)in <0x0005a> (wrapper
+delegate-invoke)
+System.MulticastDelegate:invoke_void_HtmlTextWriter_Control
+(System.Web.UI.HtmlTextWriter,System.Web.UI.Control)in <0x00049>
+System.Web.UI.Control:RenderChildren (System.Web.UI.HtmlTextWriter)
+
+Expected Results:
+Shouldn't throw an exception.
+
+How often does this happen?
+Any time a page with the control is hit.
+
+
+Additional Information:
+I'm just getting started with bugzilla/cvs/etc, so please be patient.
+
+The problem is called by a bad implementation of
+System.ComponentModel.AttributeCollection:GetDefaultAttribute throws
+MissingMethodException. It assumes that the attribute has a default
+constructor, and not all attributes do.
+
+Here's a replacement GetDefaultAttribute (I don't have my system set up
+for patching yet, but I promise for the next bug.) that uses
+GetConstructor with a check rather than an exception.
+
+ protected Attribute GetDefaultAttribute (Type
+attributeType)
+ {
+ Attribute attr = null;
+ BindingFlags bf = BindingFlags.Public |
+BindingFlags.Static;
+
+ FieldInfo def = attributeType.GetField
+("Default", bf);
+ if (def == null) {
+ ConstructorInfo constructorInfo =
+attributeType.GetConstructor (new Type[0]);
+ if (constructorInfo != null)
+ attr = (Attribute)
+constructorInfo.Invoke (new Object[0]);
+ if (attr != null && !
+attr.IsDefaultAttribute ())
+ attr = null;
+ } else {
+ attr = (Attribute) def.GetValue (null);
+ }
+
+ return attr;
+ }