ApplicationStatusEvents throws COM exception

658
1
01-06-2011 09:27 AM
KenSimoncic
New Contributor
I have some code that worked in VB6 (Arc 9.3) but is now throwing a COM error in VB.NET (Arc 10).
The code  declares at the top:

Private WithEvents pApplicationStatusEvents As ESRI.ArcGIS.Framework.ApplicationStatusEvents

Then later we have:

    Private Sub IExtension_Startup(ByRef initializationData As Object) _
    Implements ESRI.ArcGIS.esriSystem.IExtension.Startup
        Try
            If (TypeOf initializationData Is ESRI.ArcGIS.Framework.IApplication) Then
                m_pApp = initializationData
                pApplicationStatusEvents = m_pApp
            End If
...

When it executes the pApplicationStatusEvents = m_pApp line, I get the following error:

Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Framework.ApplicationStatusEvents'.  This operation failed because the QueryInterface call on the COM component for the interface with IID '{...}' failed due to the following error: No such interface supported (Exception fro mHRESULT: 0x80004002 (E_NOINTERFACE)).

Does anyone know if this capability has gone away?  I think what it was supposed to do in call the Initialize method when the applications gui was fully initialized but I could be wrong.  I inherited this code and I'm not sure of all of its quirks.
0 Kudos
1 Reply
AlexanderGray
Occasional Contributor III
Events in .NET are still there, you just need to set them up differently.  The developer help for .net explains how to do it

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_wire_ArcObjects_...
0 Kudos