A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

object that has been separated from its underlying RCW



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 30th 09, 12:30 PM posted to microsoft.public.outlook.program_addins
j
external usenet poster
 
Posts: 109
Default object that has been separated from its underlying RCW

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??
Ads
  #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
  #3  
Old July 30th 09, 01:00 PM posted to microsoft.public.outlook.program_addins
j
external usenet poster
 
Posts: 109
Default object that has been separated from its underlying RCW

On Jul 30, 2:55*pm, Tobias Böhm wrote:
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


Thanks,

I see, however i access the Outlook excplorer's ui object.
You want to point that now even in Outlook (without any programming)
impossible to access the File Menu for example??
The Outlook is alive.
I don't understant this.

Please explain, thanks in advance.
  #4  
Old July 30th 09, 01:03 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., 14:00, j wrote:
On Jul 30, 2:55*pm, Tobias Böhm wrote:



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


Thanks,

I see, however i access the Outlook excplorer's ui object.
You want to point that now even in Outlook (without any programming)
impossible to access the File Menu for example??
The Outlook is alive.
I don't understant this.

Please explain, thanks in advance.


If that happens even when you just use Outlook, maybe it's another Add-
In causing the problem. Try disabling installed Add-Ins.

Tobias
  #5  
Old July 30th 09, 01:22 PM posted to microsoft.public.outlook.program_addins
j
external usenet poster
 
Posts: 109
Default object that has been separated from its underlying RCW

On Jul 30, 3:03*pm, Tobias Böhm wrote:
On 30 Jul., 14:00, j wrote:





On Jul 30, 2:55*pm, Tobias Böhm wrote:


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


Thanks,


I see, however i access the Outlook excplorer's ui object.
You want to point that now even in Outlook (without any programming)
impossible to access the File Menu for example??
The Outlook is alive.
I don't understant this.


Please explain, thanks in advance.


If that happens even when you just use Outlook, maybe it's another Add-
In causing the problem. Try disabling installed Add-Ins.

Tobias- Hide quoted text -

- Show quoted text -


There is no other addIns.
My question is if for expample i execute the following line of code:
-- myExplorer is active explorer
Marshal.ReleaseCOMObject(myExplorer.CommandBars);

so now, i'll failed to work with Otulook's Menu ??


  #6  
Old July 30th 09, 02:12 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default object that has been separated from its underlying RCW

When the Interop wrapper for a COM object (RCW) is released it releases the
references to that object and you get that error when you try to then access
that object. That is caused by calling Marshal.ReleaseComObject() on the
object, or a similar call such as FinalReleaseComObject(), as explained by
Tobias.

One thing to be aware of is that if you have an Explorer object (or any
other) and you pass a copy of that Explorer to a procedure and in that
procedure you call one of the release methods the original object is
released, not just the copy passed to the procedu

DoFoobarSub(_explorer);
if (_explorer.Caption == "Inbox") // fires RCW exception
{
}


private void DoFoobarSub(Outlook.Explorer exp)
{
// whatever
Marshal.ReleaseComObject(exp);
}

Any attempt to access _explorer after calling that DoFoobarSub() method will
fire an RCW exception.

In addition, although you say there are no other addins at all, you also
have to bear that in mind. If your managed code addin is not shimmed to
provide an exclusive AppDomain for it then things like this or any
exceptions or crashes in any managed code addin in the default AppDomain
will affect your addin. That's why shimming is so important for managed code
addins.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"j" wrote in message
...
On Jul 30, 3:03 pm, Tobias Böhm wrote:
On 30 Jul., 14:00, j wrote:





On Jul 30, 2:55 pm, Tobias Böhm wrote:


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


Thanks,


I see, however i access the Outlook excplorer's ui object.
You want to point that now even in Outlook (without any programming)
impossible to access the File Menu for example??
The Outlook is alive.
I don't understant this.


Please explain, thanks in advance.


If that happens even when you just use Outlook, maybe it's another Add-
In causing the problem. Try disabling installed Add-Ins.

Tobias- Hide quoted text -

- Show quoted text -


There is no other addIns.
My question is if for expample i execute the following line of code:
-- myExplorer is active explorer
Marshal.ReleaseCOMObject(myExplorer.CommandBars);

so now, i'll failed to work with Otulook's Menu ??


  #7  
Old July 30th 09, 03:07 PM posted to microsoft.public.outlook.program_addins
j
external usenet poster
 
Posts: 109
Default object that has been separated from its underlying RCW

On Jul 30, 4:12*pm, "Ken Slovak - [MVP - Outlook]"
wrote:
When the Interop wrapper for a COM object (RCW) is released it releases the
references to that object and you get that error when you try to then access
that object. That is caused by calling Marshal.ReleaseComObject() on the
object, or a similar call such as FinalReleaseComObject(), as explained by
Tobias.

One thing to be aware of is that if you have an Explorer object (or any
other) and you pass a copy of that Explorer to a procedure and in that
procedure you call one of the release methods the original object is
released, not just the copy passed to the procedu

DoFoobarSub(_explorer);
if (_explorer.Caption == "Inbox") // fires RCW exception
{

}

private void DoFoobarSub(Outlook.Explorer exp)
{
* * // whatever
* * Marshal.ReleaseComObject(exp);

}

Any attempt to access _explorer after calling that DoFoobarSub() method will
fire an RCW exception.

In addition, although you say there are no other addins at all, you also
have to bear that in mind. If your managed code addin is not shimmed to
provide an exclusive AppDomain for it then things like this or any
exceptions or crashes in any managed code addin in the default AppDomain
will affect your addin. That's why shimming is so important for managed code
addins.
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm

"j" wrote in message

...
On Jul 30, 3:03 pm, Tobias Böhm wrote:





On 30 Jul., 14:00, j wrote:


On Jul 30, 2:55 pm, Tobias Böhm wrote:


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


Thanks,


I see, however i access the Outlook excplorer's ui object.
You want to point that now even in Outlook (without any programming)
impossible to access the File Menu for example??
The Outlook is alive.
I don't understant this.


Please explain, thanks in advance.


If that happens even when you just use Outlook, maybe it's another Add-
In causing the problem. Try disabling installed Add-Ins.


Tobias- Hide quoted text -


- Show quoted text -


There is no other addIns.
My question is if for expample i execute the following line of *code:
-- myExplorer is active explorer
Marshal.ReleaseCOMObject(myExplorer.CommandBars);

so now, i'll failed to work with Otulook's Menu ??- Hide quoted text -

- Show quoted text -


The AddIn provides an exclusive AppDomain. Also can please explain a
litle bit about shimming??

In my code i use Marshal.ReleaseCOMObject(...). I do it because of rpc
conneciton known issue limitation.
There is a command netstat -a
What should i see there?? How can i recognize open rpc conenction in
Outlook??

Many many thanks.
  #8  
Old July 30th 09, 04:45 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default object that has been separated from its underlying RCW

For information on netstat post in a networking group or google for the
information.

The RPC channel issue is real but you have to use common sense as to when
you call ReleaseComObject(). You do that mainly in loops on subsidiary
properties such as a mail item within a loop accessing the Items collection
of a folder. You never call that if you need to re-use the object again,
unless you explicitly instantiate another instance of the object afterwards.

You should always strive to declare objects at the lowest scope where they
will be needed, and release them when done with the objects, but don't
release objects you will have further use for.

Shimming provides a unique AppDomain for a managed code application. You
have to explicitly shim an addin or use VSTO, which does the shimming for
you. Either you write your own shimming code or you use the COM Shim Wizard
to create the shim for you. Shimming doesn't happen without an explicit shim
that loads your addin. If there is no shim then your code is running in a
common AppDomain and not an exclusive one.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"j" wrote in message
...
snip

The AddIn provides an exclusive AppDomain. Also can please explain a
litle bit about shimming??

In my code i use Marshal.ReleaseCOMObject(...). I do it because of rpc
conneciton known issue limitation.
There is a command netstat -a
What should i see there?? How can i recognize open rpc conenction in
Outlook??

Many many thanks.

  #9  
Old July 30th 09, 08:40 PM posted to microsoft.public.outlook.program_addins
j
external usenet poster
 
Posts: 109
Default object that has been separated from its underlying RCW

On Jul 30, 6:45*pm, "Ken Slovak - [MVP - Outlook]"
wrote:
For information on netstat post in a networking group or google for the
information.

The RPC channel issue is real but you have to use common sense as to when
you call ReleaseComObject(). You do that mainly in loops on subsidiary
properties such as a mail item within a loop accessing the Items collection
of a folder. You never call that if you need to re-use the object again,
unless you explicitly instantiate another instance of the object afterwards.

You should always strive to declare objects at the lowest scope where they
will be needed, and release them when done with the objects, but don't
release objects you will have further use for.

Shimming provides a unique AppDomain for a managed code application. You
have to explicitly shim an addin or use VSTO, which does the shimming for
you. Either you write your own shimming code or you use the COM Shim Wizard
to create the shim for you. Shimming doesn't happen without an explicit shim
that loads your addin. If there is no shim then your code is running in a
common AppDomain and not an exclusive one.

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm

"j" wrote in message

...
snip

The AddIn provides an exclusive AppDomain. Also can please explain a
litle bit about shimming??

In my code i use Marshal.ReleaseCOMObject(...). I do it because of rpc
conneciton known issue limitation.
There is a command netstat -a
What should i see there?? How can i recognize open rpc conenction in
Outlook??

Many many thanks.


Thanks for such details explanation.
So, in case i'll not use VSTO and will develop shared AddIn, i'll to
build shim by myself??
There is no wizard for it?
  #10  
Old July 30th 09, 09:17 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default object that has been separated from its underlying RCW

As I said in my last post:

Either you write your own shimming code or you use the COM Shim Wizard to
create the shim for you. There is a COM Shim Wizard.

For VS 2005 you download it from MS, google for that, for VS 2008 it's
built-in.

As I also said my last post: VSTO does the shimming for you.

If shimming is the only reason you have not to use VSTO then you picked the
wrong reason.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"j" wrote in message
...
snip

Thanks for such details explanation.
So, in case i'll not use VSTO and will develop shared AddIn, i'll to
build shim by myself??
There is no wizard for it?

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
COM object that has been separated from its underlying RCW Nagaraj Add-ins for Outlook 1 April 9th 09 02:29 PM
How to get to email from Word - separated from original thread Graham Mayor[_2_] Outlook - General Queries 0 April 23rd 08 03:53 PM
Your digital ID name cannot be found by the underlying security system Jorge Ramos Outlook - General Queries 15 February 6th 08 09:53 AM
Why does the Address property of the Recipient object in the Outlook object model look funny? Omatase Outlook - General Queries 2 July 13th 07 09:09 PM
Outlook 2003 - Pop Account & Exchage Account in two separated personal folders roy Outlook - General Queries 1 June 28th 06 06:13 PM


All times are GMT +1. The time now is 08:50 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.