How to cast a "System.__ComObject"?

  • Thread starter Thread starter MeAgin
  • Start date Start date
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
 
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
 
Back
Top