S
sundog2000
I am writing my first VB.net program and I am struggling to figure out
how to attach an event to a method, when the event is part of an
interface that the class implements.
I have declared a delegate function, a public event, and the class
object (g_pFeedManager) is first dim'ed as an interface. Later it is
new'd at a class that implements that interface. However, when I try
to call AddHandler to attach the event to a function, I have problems.
It doesn't recognize the event as being part of the class - actually
the error says it doesn't recognize it as part of the interface that it
was originally dim'ed as.
This program uses ArcGIS libraries, but I think the problem is my
knowledge of the language not a characterstic of the libraries. Here
is some relevant code:
'The delegate function
Public Delegate Sub PositionUpdatedEventHandler(ByVal position As
ESRI.ArcGIS.Carto.esriGpsPositionInfo, ByVal estimate As Boolean)
'The event
Public Event PositionUpdated As PositionUpdatedEventHandler
'Implements
ESRI.ArcGIS.Carto.IRealTimeFeedManagerEvents.PositionUpdated
'Dimming the object as an interface
Public g_pFeedManager As ESRI.ArcGIS.Carto.IRealTimeFeedManager
'in a later function, allocating memory for the object.
g_pFeedManager = New ESRI.ArcGIS.Carto.RealTimeFeedManager
'This function gives the error.
'error BC30676: 'PositionUpdated' is not an event of
'ESRI.ArcGIS.Carto.IRealTimeFeedManager'.
AddHandler g_pFeedManager.PositionUpdated, AddressOf OnPositionChange
**
So I don't know how to refer to the event. I tried setting up a test
case just like this:
Dim test As ESRI.ArcGIS.Carto.IRealTimeFeedManagerEvents
AddHandler test.PositionUpdated, AddressOf OnPositionChange
So test is definitely of the proper type and the error message is:
error BC30676: 'PositionUpdated' is not an event of
'ESRI.ArcGIS.Carto.IRealTimeFeedManagerEvents'.
Although clearly it is of the correct type, it still gives me this
error.
Any ideas?
Thanks,
Nick
how to attach an event to a method, when the event is part of an
interface that the class implements.
I have declared a delegate function, a public event, and the class
object (g_pFeedManager) is first dim'ed as an interface. Later it is
new'd at a class that implements that interface. However, when I try
to call AddHandler to attach the event to a function, I have problems.
It doesn't recognize the event as being part of the class - actually
the error says it doesn't recognize it as part of the interface that it
was originally dim'ed as.
This program uses ArcGIS libraries, but I think the problem is my
knowledge of the language not a characterstic of the libraries. Here
is some relevant code:
'The delegate function
Public Delegate Sub PositionUpdatedEventHandler(ByVal position As
ESRI.ArcGIS.Carto.esriGpsPositionInfo, ByVal estimate As Boolean)
'The event
Public Event PositionUpdated As PositionUpdatedEventHandler
'Implements
ESRI.ArcGIS.Carto.IRealTimeFeedManagerEvents.PositionUpdated
'Dimming the object as an interface
Public g_pFeedManager As ESRI.ArcGIS.Carto.IRealTimeFeedManager
'in a later function, allocating memory for the object.
g_pFeedManager = New ESRI.ArcGIS.Carto.RealTimeFeedManager
'This function gives the error.
'error BC30676: 'PositionUpdated' is not an event of
'ESRI.ArcGIS.Carto.IRealTimeFeedManager'.
AddHandler g_pFeedManager.PositionUpdated, AddressOf OnPositionChange
**
So I don't know how to refer to the event. I tried setting up a test
case just like this:
Dim test As ESRI.ArcGIS.Carto.IRealTimeFeedManagerEvents
AddHandler test.PositionUpdated, AddressOf OnPositionChange
So test is definitely of the proper type and the error message is:
error BC30676: 'PositionUpdated' is not an event of
'ESRI.ArcGIS.Carto.IRealTimeFeedManagerEvents'.
Although clearly it is of the correct type, it still gives me this
error.
Any ideas?
Thanks,
Nick