PC Review


Reply
Thread Tools Rate Thread

How to cast a "System.__ComObject"?

 
 
MeAgin
Guest
Posts: n/a
 
      6th Feb 2007
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








 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      6th Feb 2007

>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.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Unable to cast COM object of type 'System.__ComObject' to interfac =?Utf-8?B?U0c=?= Microsoft Dot NET 0 20th Jan 2006 02:27 PM
Unable to cast COM object of type 'System.__ComObject' =?Utf-8?B?U3RldmUgV2lsa2luc29u?= Microsoft Dot NET Framework 0 13th Jan 2006 01:40 PM
Cast from string "Thu Jul 21 00:00:00 UTC+0100 200" to type 'Date'is not valid(System.InvalidCastException) Kiran Microsoft VB .NET 10 4th Aug 2005 04:05 PM
Unable to cast object of type System.__ComObject Tony Microsoft C# .NET 1 29th Oct 2004 02:58 PM
"System.InvalidCastException: Specified cast is not valid." during connection.open Roy Lawson Microsoft ASP .NET 12 25th Oct 2004 06:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 AM.