Getting a System.Runtime.InteropServices.COMException

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

Getting a System.Runtime.InteropServices.COMException
InteropServices.COMException thrown when closeing a tab in Internet Exploror 11.0 
Michael Hutchinson


Guest


I am getting a type System.Runtime.InteropServices.COMException when closing the tab with IE 11.0.9600.17691 on Windows 7. Have seen the same behavior with IE 11 on Windows 8.1.

I was not expecting a OnPropertyChange event during tab closure.

The code within OnPropertyChange is checking for HTMLDoc != null


Detailed technical information follows: 
---
(Inner Exception)
(Inner Exception)
Date and Time:         4/15/2015 2:00:07 PM
Machine Name:          XXXXXXXXXXXXXX 
IP Address:            XXXXXXXXXXXXXX 
Current User:          XXXXXXXXXXXXXX

Application Domain:    C:Program Files (x86)XXXXXXXXXXXXXX
Assembly Codebase:     file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.IE/9.2.6124.0__4416dd98f0861965/AddinExpress.IE.dll
Assembly Full Name:    AddinExpress.IE, Version=9.2.6124.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version:      9.2.6124.0

Exception Source:      
Exception Type:        System.Runtime.InteropServices.COMException
Exception Message:     Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
Exception Target Site: Object reference not set to an instance of an object.

---- Stack Trace ----



(Outer Exception)
Date and Time:         4/15/2015 2:00:07 PM
Machine Name:          XXXXXXXXXXXXXX
IP Address:            XXXXXXXXXXXXXX
Current User:          XXXXXXXXXXXXXX

Application Domain:    C:Program Files (x86)XXXXXXXXXXXXXX
Assembly Codebase:     file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
Assembly Full Name:    mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version:      2.0.0.0

Exception Source:      mscorlib
Exception Type:        System.Reflection.TargetInvocationException
Exception Message:     Exception has been thrown by the target of an invocation.
Exception Target Site: InvokeDispMethod

---- Stack Trace ----
   System.RuntimeType.InvokeDispMethod(name As String, invokeAttr As BindingFlags, target As Object, args As Object[], byrefModifiers As Boolean[], culture As Int32, namedParameters As String[])
       mscorlib.dll: N 00000 (0x0) JIT 
   System.RuntimeType.InvokeMember(name As String, bindingFlags As BindingFlags, binder As Binder, target As Object, providedArgs As Object[], modifiers As ParameterModifier[], culture As CultureInfo, namedParams As String[])
       mscorlib.dll: N 0488 (0x1E8) IL 
   System.Type.InvokeMember(name As String, invokeAttr As BindingFlags, binder As Binder, target As Object, args As Object[])
       mscorlib.dll: N 0000 (0x0) IL 
   AddinExpress.IE.ADXIEModule.get_HTMLDocumentObj()
       mscorlib.dll: N 0008 (0x8) IL 
   XXXXXXXXXXXXXX.IEModule.get_HTMLDoc()
       mscorlib.dll: N 0000 (0x0) IL 
   XXXXXXXXXXXXXX.IEModule.adxiehtmlDocEvents_OnPropertyChange(sender As Object, eventObject As Object)
       mscorlib.dll: N 0000 (0x0) IL 
   AddinExpress.IE.ADXIEHTMLDocEvents.DoOnPropertyChange(pEvtObj As Object)
       mscorlib.dll: N 0021 (0x15) IL 
   AddinExpress.IE.IEHTMLEventsInternal.OnPropertyChange(pEvtObj As Object)
       mscorlib.dll: N 0000 (0x0) IL 
   AddinExpress.IE.HTMLDocumentEvents_SinkHelper.AddinExpress.IE.IHTMLDocumentEvents2.onpropertychange(pEvtObj As Object)
       mscorlib.dll: N 0008 (0x8) IL 



(Outer Exception)
Date and Time:         4/15/2015 2:00:07 PM
Machine Name:          XXXXXXXXXXXXXX
IP Address:            XXXXXXXXXXXXXX
Current User:          XXXXXXXXXXXXXX

Application Domain:    C:Program Files (x86)XXXXXXXXXXXXXX
Assembly Codebase:     file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.IE/9.2.6124.0__4416dd98f0861965/AddinExpress.IE.dll
Assembly Full Name:    AddinExpress.IE, Version=9.2.6124.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version:      9.2.6124.0

Exception Source:      
Exception Type:        AddinExpress.IE.ADXIEExternalException
Exception Message:     An error has occurred in the code of the extension.
Exception Target Site: Object reference not set to an instance of an object.

---- Stack Trace ----



Any ideas why this is occurring or what I need to add to the OnPropertyChange handler to prevent it?

Regards,
Michael
Posted 15 Apr, 2015 14:28:32 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Michael,

It seems that the HTML document is not accessible in OnPropertyChange when the tab is closed. Please try to wrap 'HTMLDoc != null' with try...catch.
Posted 16 Apr, 2015 06:46:12 Top
Michael Hutchinson


Guest


Sergey,

Thanks for the suggestion.

I've actually added the exception handler to the HTMLDoc get code itself.

I will see if I can reproduce the issue with the fix implemented this way.

        private mshtml.HTMLDocument HTMLDoc
        {
            get
            {
                try
                {
                    return (this.HTMLDocumentObj as mshtml.HTMLDocument);
                }
                catch (Exception) 
                {
                    return null;
                }
            }
        }


Might I suggest that you add something like this into your VS Add-in that generates the project code for the next release so that future users don't have the same problem?

Note: I added the handler to IEApp getter as well.

Regards,
Michael
Posted 17 Apr, 2015 14:39:10 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Michael,

Thank you for the suggestion.
Posted 20 Apr, 2015 05:46:20 Top