How to cast a "System.__ComObject"?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MeAgin

    #1

    How to cast a "System.__ComObject"?

    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.__ComOb ject' 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








  • Mattias Sjögren

    #2
    Re: How to cast a "System.__ ComObject" ?

    >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

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...