|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using an event defined in an interfacehow 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 "sundog2000" <sundog2***@gmail.com> schrieb: \\\>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. Public Interface IFoo Event Goo(ByVal sender As Object, ByVal e As EventArgs) End Interface Public Class Sample Implements IFoo Public Event Goo( _ ByVal sender As Object, _ ByVal e As EventArgs _ ) Implements IFoo.Goo Public Sub Test() RaiseEvent Goo(Me, EventArgs.Empty) End Sub End Class .. .. .. Dim f As IFoo = New Sample AddHandler f.Goo, AddressOf Me.Sample_Goo /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
How to debug this?
Mixing VB variables with standard text to output text file foxpro table hosed up when called 2nd time from VB.net Line Numbers in RichTextBox.. OT: ILMerge Polymorphic XML Serialized Array Creating array on the fly as a parameter to a subroutine? SaveFileDialog TCPClient and TCPListener over the network IPC Examples in VB.net? |
|||||||||||||||||||||||