WIA & C#: TypeDescriptionProvider.GetTypeDescriptor() instanceparameter is null?

  • Thread starter Thread starter Edward Beach
  • Start date Start date
E

Edward Beach

Hello,

I'm implementing an application with C# and WIA scripting and I'm
trying to display a WIA Device object in a property grid. After some
searching it seems like I want to model my solution after this example
(http://msdn.microsoft.com/en-us/magazine/cc163804.aspx) that involves
implementing a TypeDescriptionProvider and registering it via
TypeDescriptor.AddProvider().

When I set my Device object as the SelectedObject in my property grid,
I trace the through my implementation of "public override
ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object
instance)" but the instance parameter is null. This is unfortunate
since I need the instance to make the following calls to the WIA
Device's properties to generate the displayed properties in the
TypeDescriptor.

Could anybody help me? Why would the instance be null? And what
could I do to fix it, or work around it?

Thanks!
 
Hello,

I'm implementing an application with C# and WIA scripting and I'm
trying to display a WIA Device object in a property grid. After some
searching it seems like I want to model my solution after this example
(http://msdn.microsoft.com/en-us/magazine/cc163804.aspx) that involves
implementing a TypeDescriptionProvider and registering it via
TypeDescriptor.AddProvider().

When I set my Device object as the SelectedObject in my property grid,
I trace the through my implementation of "public override
ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object
instance)" but the instance parameter is null. This is unfortunate
since I need the instance to make the following calls to the WIA
Device's properties to generate the displayed properties in the
TypeDescriptor.

Could anybody help me? Why would the instance be null? And what
could I do to fix it, or work around it?

Thanks!


I didn't use this approach but may I ask why do you need the instance
for?

Don't you already know all the definitions of properties at design time?

I've implemented ICustomTypeDescriptor and all you know is your type.
Whan PropertyGrid gathers the values of an instance it will call
GetValue() passing "component" which holds the instance you need to get
tha actual value.
 
Back
Top