Hi. I have an public interface class in VB that I'm trying to use in C# (I'm converting my ways to C# - like it!!). I'm getting the following error when trying to code for the event handler:
C:\<path>\newDevice.cs(7,18): error CS0536: 'deviceInCsImplimentsEquipIL.newDevice' does not implement interface member 'EquipmentIL.EquipIC.Methods.ConnectionEstablished'. 'deviceInCsImplimentsEquipIL.newDevice.ConnectionEstablished' is either static, not public, or has the wrong return type.
Here are two events from the VB portion of the interface:
Event ConnectionEstablished(ByVal id As Long, ByVal address As String, ByVal port As Integer)Event NewData(ByVal id As Long, ByVal message As String, ByVal readStatus As Long)
Here's my two attempts for handling the event, both resulting in the same type of error:
public delegate void ConnectionEstablishedEventHandler(long id, string address, int port);public event ConnectionEstablishedEventHandler ConnectionEstablished {
add {
}
remove {
}
} public delegate void NewDataEventHandler(long id, string message, long readStatus);
public event NewDataEventHandler NewData;
Any thoughts as to what I need to fix this
Thanks in advance,
Dave

Raising an event in C# that impliments a VB interface?
WoodrowS
Hi,
Do as the error said, implement the two interface members.
Thanks
geovana costa rocha
Try:
namespace deviceInCsImplimentsEquipIL {
public class newDevice : EquipmentIL.EquipIC.Methods {
public event ConnectionEstablishedEventHandler ConnectionEstablished;
public event NewDataEventHandler NewData;
}
The only time you need the acessor is when you try to explicitly implement the interface.
Gess Man
Figo: I thought I did that by declaring the class as an interface and declaring the events as public with the same calling parameters. The other methods in the interface are implemented just fine, but I can't seem to find the correct syntax for the events.
The (much abreviated) interface in VB is:
Public
Class EquipICPublic Interface Methods Event ConnectionEstablished(ByVal id As Long, ByVal address As String, ByVal port As Integer)
Event NewData(ByVal id As Long, ByVal message As String, ByVal readStatus As Long)
End Interface
End Class
Again, the CS code (the class that is using the interface by using the reference to EquipmentIL) is
namespace
deviceInCsImplimentsEquipIL {public class newDevice : EquipmentIL.EquipIC.Methods {
public delegate void ConnectionEstablishedEventHandler(long id, string address, int port);
public delegate void NewDataEventHandler(long id, string message, long readStatus);public event ConnectionEstablishedEventHandler ConnectionEstablished {
add {
}
remove {
}
}
public event NewDataEventHandler NewData;
}
Both ways of declaring the two events result in the same type of error.
2162
Sean,
That almost did it! Since the two classes are in different namespaces, the following is the fixed code in CS that works.
Thanks,
Dave
namespace deviceInCsImplimentsEquipIL {
public event EquipmentIL.EquipIC.Methods.ConnectionEstablishedEventHandler ConnectionEstablished;public class newDevice : EquipmentIL.EquipIC.Methods {
public event EquipmentIL.EquipIC.Methods.NewDataEventHandler NewData;
}
}