On Jul 30, 4:12 pm, "
<kenslo...@mvps.org> 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 procedure:
> 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.
> >
> http://www.slovaktech.com
> "j" <Evgeny...@gmail.com> wrote in message
> news:435bd762-ea1d-442e-8aa4-9587c7f66d06@b15g2000yqd.googlegroups.com...
> On Jul 30, 3:03 pm, Tobias Böhm <boehm.t...@googlemail.com> wrote:
>
> > On 30 Jul., 14:00, j <Evgeny...@gmail.com> wrote:
>
> > > On Jul 30, 2:55 pm, Tobias Böhm <boehm.t...@googlemail.com> wrote:
>
> > > > On 30 Jul., 13:30, j <Evgeny...@gmail.com> 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.InvalidComObjectException: 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-
>
>
> 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 ??-
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.