[Mono-list] TypeInitializationException in ComponentModel
kobruleht2 at hot.ee
Tue Oct 23 09:56:11 EDT 2007
> TypeDescriptors and properties added to types at
> runtime are highly unrelated features. You don't really
> add properties to types using TypeDescriptors. Properties
> added this way are only visible to UI Designers and other
> components that explicitly deal with TypeDescriptors (like
> PropertyGrid, IIRC).
> If you really meant this kind of extension, you could
> implement ICustomTypeDescriptor. It's slightly more work
> than using the new TypeDescriptionProvider, but it's at
> least possible.
Marc Gravell reply:
Actually, TypeDescriptionProvider is the 2.0 *extension* to
ICustomTypeDescriptor, allowing for separation of concerns between the
entity class and the class dealing with how to represent it - and
allowing for type-centric (rather than instance-centric) rules. Any
code that supports ICustomTypeDescriptor would *typically* be using
TypeDescriptor.GetProperties(), which supports both
ICustomTypeDescriptor and TypeDesriptionProvider (and indeed, regular
If mono has an implementation that works for ICustomTypeDescriptor,
but fails for TypeDescriptionProvider, then I suggest that the mono
support for TypeDescriptionProvider is flawed, as it has failed in its
Generally, in (non mono) .NET code, the core binding code worries
about all of this for you - in particular via the route:
BindingContext -> BindingManagerBase -> GetItemProperties()
Equally, the behind-the-scenes binding code deals with *other* models,
such as ITypedList (which *also* has a GetItemProperties() method).
And the consumer shouldn't have to worry themselves about any of it.
PropertyGrid (which you cited) is an exception to most rules, in that
(for building the tree) it is more worried about what the
TypeConverter has to say (via GetProperties()) - but note that for
simple implementations (like ExandableObjectConverter) it simply uses
TypeDescriptor.GetProperties(), so again the ICustomTypeDescriptor and
TypeDescriptionProvider rules are observed.
As I understand from this ICustomTypeDescriptor cannot also be used to
implement dynamic properties since it has the same issues as TypeDescrptor.
So only way to add dynamic properties to objects which gets populated from
database by nhiberante is to use dynamic compilation ?
More information about the Mono-list