COM object that has been separated from its underlying RCW cannot be used.

Add-in Express™ Support Service
That's what is more important than anything else

COM object that has been separated from its underlying RCW cannot be used.
 
Bargholz Thomas




Posts: 236
Joined: 2006-12-18
Hi,

we have an Outlook add-on, where a few users on occcation gets an error from our Outlook add-in, when they on an e-mail inspector clicks Reply. This only happens for a few users, and not all the time, just on occations.

The error comes from InspectorClose (from stacktrace), but we don't have any code for InspectorClose. We do however have code for InspectorActivate, where we check the type of item in the inspector, where we need to do some work if it's an task item. We don't release the , as it is passed in the event, but we do release the item:


private void adxOutlookEvents_InspectorActivate(object sender, object inspector, string folderName)
{
if (inspector != null)
{
    Outlook.Inspector insp = inspector as Outlook.Inspector;
    try
    {
        currentItem = insp.CurrentItem;
        if (currentItem is Outlook.TaskItem)
        { ... }
    }
    finally
    {
        if (currentItem != null)
            Marshal.ReleaseComObject(currentItem);
    }
}
}


We use Add-in-express version 8.3.4393.2005.

Thew error is this :

Exception Source: mscorlib
Exception Type: System.Runtime.InteropServices.InvalidComObjectException
Exception Message: COM object that has been separated from its underlying RCW cannot be used.
Exception Target Site: GetIUnknownForObjectNative

---- Stack Trace ----
System.Runtime.InteropServices.Marshal.GetIUnknownForObjectNative(o As Object, onlyInContext As Boolean)
AddinExpress.OL.2005.DLL: N 00000 (0x0) JIT
AddinExpress.OL.OutlookUtils.NewRefObj(Obj As Object)
AddinExpress.OL.2005.DLL: N 0006 (0x6) IL
AddinExpress.OL.ADXOlInspectorArguments..ctor(FormsManager As ADXOlFormsManager, InspectorObj As Object, ItemObj As Object, InspectorWindowHandle As IntPtr, CodeContext As ADXOlCodeContext)
AddinExpress.OL.2005.DLL: N 0237 (0xED) IL
AddinExpress.OL.OlInspectorEvents_BaseLogic.DoInspectorClose()
AddinExpress.OL.2005.DLL: N 0036 (0x24) IL

Best regards
Thomas
Posted 15 Mar, 2017 05:01:14 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hello Thomas,

Make sure you don't release ADXOlForm.InspectorObj.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2017 07:18:05 Top
Bargholz Thomas




Posts: 236
Joined: 2006-12-18
Hi Andrei,

I've been through the code looking for InspectorObj, and it turned out, that in one of the AdxOlForms used in Inspector mode for e-mails, InspectorObj was indeed released in the ADXAfterFormShow. This is now removed, and it appareas to have solved the issues - thanks for your help :)

Regards, Thomas
Posted 15 Mar, 2017 08:55:55 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
You are welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2017 09:14:55 Top