How to cast a "System.__ComObject"?

M

MeAgin

Hi all,

When I try to cast an object (ListBox control in an outlook mail form)
retrieved from an outlook add-in it is giving the error,

Unable to cast COM object of type 'System.__ComObject' to class type
'System.Windows.Forms.ListBox'. Instances of types that represent COM
components cannot be cast to types that do not represent COM components;
however they can be cast to interfaces as long as the underlying COM
component supports QueryInterface calls for the IID of the interface.
How can I cast my object to an interface so I can use it as a normal windows
ListBox?


Thanks.
Nadee
 
M

Mattias Sjögren

How can I cast my object to an interface so I can use it as a normal windows
ListBox?

You probably can't. It would only work if the Outlook form actually
was built with Windows Forms.


Mattias
 

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