View Single Post
  #2  
Old July 30th 09, 12:55 PM posted to microsoft.public.outlook.program_addins
Tobias Böhm
external usenet poster
 
Posts: 13
Default object that has been separated from its underlying RCW

On 30 Jul., 13:30, j wrote:
Hi All,

what can be reason for this??
i'm trying to retrieve commandsBar, and once in a while got this
strange exception
within Outlook 2003.

System.Runtime.InteropServices.InvalidComObjectExc eption: COM object
that has been separated from its underlying RCW cannot be used.
* *at Microsoft.Office.Interop.Outlook.ExplorerClass.get _CommandBars()

Any ideas??


Hi,

the reason for this is that you are using a COM object that is already
released.

Following code will throw that exception:

Outlook.MailItem mailItem = activeInspector.CurrentItem;
Marshal.ReleaseCOMObject(mailItem);
string mailItemSubject = mailItem.Subject;

Hope that helps,
Tobias
Ads