franck DAMMANN
Posts: 41
Joined: 2021-01-26
|
Dear all,
Since an Outlook upgrade, I'm facing a bug on my Oultook Addin which is already deployed, but by asking for the StackTrace to my customer, I'm not able to find the root cause (even if I understand the error which is: COM object that has been separated from its underlying RCW cannot be used
Here is a subpart of the StackTrace:
OlInspectorEvents_10_SinkHelper.DoInspectorClose: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
Exception time: 07/10/2022 07:38:33
à System.Runtime.InteropServices.Marshal.GetIUnknownForObjectNative(Object o, Boolean onlyInContext)
à System.Runtime.InteropServices.Marshal.GetIUnknownForObject(Object o)
à AddinExpress.OL.OutlookUtils.NewRefObj(Object Obj)
à AddinExpress.OL.ADXOlInspectorArguments..ctor(ADXOlFormsManager FormsManager, Object InspectorObj, Object ItemObj, IntPtr InspectorWindowHandle, ADXOlCodeContext CodeContext)
à AddinExpress.OL.OlInspectorEvents_BaseLogic.DoInspectorClose()
AddinExpress.OL.ADXOlFormsManager error: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
Exception time: 07/10/2022 07:38:33
AddinExpress.OL.ADXOlFormsManager error: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
Error occured in OlInspectorEvents_10_SinkHelper.DoInspectorClose . See 'Details' section to get more detailed information about the error.
Detailed technical information follows:
---
Date and Time: 07/10/2022 07:38:33
Machine Name: ------
IP Address: ------
Current User: ------
Application Domain: C:UsersddAppDataLocalMailStoneMailStone Outlook Plugin
Assembly Codebase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Assembly Full Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=---
Assembly Version: 4.0.0.0
Assembly Build Date: 06/04/2022 07:42:54
Exception Source: mscorlib
Exception Type: System.Runtime.InteropServices.InvalidComObjectException
Exception Message: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
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
System.Runtime.InteropServices.Marshal.GetIUnknownForObject(o As Object)
AddinExpress.OL.2005.DLL: N 0000 (0x0) IL
AddinExpress.OL.OutlookUtils.NewRefObj(Obj As Object)
AddinExpress.OL.2005.DLL: N 0010 (0xA) 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 0244 (0xF4) IL
AddinExpress.OL.OlInspectorEvents_BaseLogic.DoInspectorClose()
AddinExpress.OL.2005.DLL: N 0070 (0x46) IL
OlInspectorEvents_10_SinkHelper.AddinExpress.OL.IInspectorEvents_10.Activate: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
Exception time: 07/10/2022 07:48:19
à System.Runtime.InteropServices.Marshal.GetIUnknownForObjectNative(Object o, Boolean onlyInContext)
à System.Runtime.InteropServices.Marshal.GetIUnknownForObject(Object o)
à AddinExpress.OL.OutlookUtils.NewRefObj(Object Obj)
à AddinExpress.OL.ADXOlInspectorArguments..ctor(ADXOlFormsManager FormsManager, Object InspectorObj, Object ItemObj, IntPtr InspectorWindowHandle, ADXOlCodeContext CodeContext)
à AddinExpress.OL.OlInspectorEvents_BaseLogic.DoInspectorActivate()
à AddinExpress.OL.OlInspectorEvents_10_SinkHelper.AddinExpress.OL.IInspectorEvents_10.Activate()
AddinExpress.OL.ADXOlFormsManager error: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
Exception time: 07/10/2022 07:48:19
AddinExpress.OL.ADXOlFormsManager error: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
Error occured in OlInspectorEvents_10_SinkHelper.AddinExpress.OL.IInspectorEvents_10.Activate . See 'Details' section to get more detailed information about the error.
Detailed technical information follows:
---
Date and Time: 07/10/2022 07:48:19
Machine Name: -----
IP Address: -----
Current User: -----
Application Domain: C:UsersddAppDataLocalMailStoneMailStone Outlook Plugin
Assembly Codebase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Assembly Full Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=-----
Assembly Version: 4.0.0.0
Assembly Build Date: 06/04/2022 07:42:54
Exception Source: mscorlib
Exception Type: System.Runtime.InteropServices.InvalidComObjectException
Exception Message: Impossible d'utiliser un objet COM qui a ?t? s?par? de son RCW sous-jacent.
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
System.Runtime.InteropServices.Marshal.GetIUnknownForObject(o As Object)
AddinExpress.OL.2005.DLL: N 0000 (0x0) IL
AddinExpress.OL.OutlookUtils.NewRefObj(Obj As Object)
AddinExpress.OL.2005.DLL: N 0010 (0xA) 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 0244 (0xF4) IL
AddinExpress.OL.OlInspectorEvents_BaseLogic.DoInspectorActivate()
AddinExpress.OL.2005.DLL: N 0052 (0x34) IL
AddinExpress.OL.OlInspectorEvents_10_SinkHelper.AddinExpress.OL.IInspectorEvents_10.Activate()
AddinExpress.OL.2005.DLL: N 0026 (0x1A) IL
As far as I understand, it seems that I'm trying to access an Object which is no more available somewhere in adxOutlookAppEvents1_ExplorerActivate or adxOutlookEvents_InspectorActivate but in both functions I implemented try catch in order to prevent any exception for the customer.
so how can I identify exactly which access is raising this error ? I'm getting used to develop in Java and where the line is clearly identified in the error...which is not the cas for dotnet !
and my second point is: how can I prevent those kind of error message on my code ? I would prefer to avoid displaying such message to my customers...
Thanks for your help !
Franck. |
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Hello Franck,
It looks like you've released an Inspector object that Add-in Express passed to your code as a parameter of an Add-in Express event. In section Release all COM objects created in your code (see the PDF file in the folder {Add-in Express}\Docs on your development PC) we describe this requirement as follows:
?Â?Ð?? Never release COM objects obtained through the parameters of events provided by Add-in Express.
To create a friendly environment for your add-in, Add-in Express creates COM objects and relies on their state. You must not release these COM objects.
For instance, the code fragment below wrongly releases the following COM object:
private void adxOutlookAppEvents1_InspectorActivate(object sender, object inspector, string folderName)
{
Outlook.Inspector theInspector = inspector as Outlook.Inspector;
Marshal.ReleaseComObject(theInspector); // this is wrong! Never release COM objects passed to your methods in a parameter of an Add-in Express event!
}
Both inspector and theInspector above point to the *same* COM object. this is because casting a COM object in .NET doesn't change anything.
In https://www.add-in-express.com/creating-addins-blog/2011/11/04/why-doesnt-excel-quit/ we describe what objects .NET creates behind the scene when a COM object is created and you will see why casting doesn't produce a new COM object in .NET.
Regards from Poland (CEST),
Andrei Smolin
Add-in Express Team Leader |
|