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


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!
 
Ad

Advertisements

S

Smola

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top