wmlanza

Listening to GraphicTracker events

Discussion created by wmlanza on Oct 6, 2011
I am trying to listen to events on the GraphicTracker class but keep getting a COM exception, just wondering what is wrong with the following code:

Public class clsCADContainer
Private WithEvents m_map As ESRI.ArcGIS.Controls.AxMapControl
Private WithEvents m_graphicTracker As GraphicTracker = New GraphicTrackerClass()

...

    Public Sub New(ByVal map As ESRI.ArcGIS.Controls.AxMapControl)
        MyBase.New()
        m_map = map
        m_graphicTracker.Initialize(TryCast(m_map.Map, IBasicMap))
       
        AddHandler m_graphicTracker.ItemDeleted, AddressOf OnGraphicTrackerItemDeleted 'Throws exception here (see below)
    End Sub


    Private Sub OnGraphicTrackerItemDeleted(item As Object)
        'Do Something
    End Sub

...
End Class



COM Error:
Error adding eventhandler to graphics tracker - Exception has been thrown by the target of an invocation.; stack=   at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
   at System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.__ComObject.CreateEventProvider(RuntimeType t)
   at System.__ComObject.GetEventProvider(RuntimeType t)
   at ESRI.ArcGIS.EngineCore.GraphicTrackerClass.add_ItemDeleted(IActiveViewEvents_ItemDeletedEventHandler A_1)
   at xTrakker_Controls.clsCADContainer..ctor(AxMapControl map) in C:\src\xSolution Suite\Releases\2011Q2\xTrakker\Source\xTrakker_Controls\classes\clsCADContainer.vb:line 26 Inner Exception: System.InvalidCastException: Unable to cast COM object of type 'ESRI.ArcGIS.EngineCore.GraphicTrackerClass' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPointContainer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B284-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
   at ESRI.ArcGIS.EngineCore.IActiveViewEvents_EventProvider..ctor(Object A_1)

Outcomes