Really pulling my hair with this ...
I have a C # project with an interface defined as:
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISerial
{
[DispId(1)]
bool Startup();
[DispId(2)]
bool Shutdown();
[DispId(3)]
bool UserInput_FloorButton(int floor_number);
[DispId(4)]
bool Initialize();
}
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISerialEvent
{
[DispId(5)]
void DataEvent();
}
[ComSourceInterfaces(typeof(ISerialEvent), typeof(ISerial))]
[ClassInterface(ClassInterfaceType.None)]
public class SerialIface : ISerial
{
public delegate void DataEvent();
public event DataEvent dEvent;
public bool Initialize()
{
if (dEvent != null)
{
dEvent();
}
}
...
}
And the VB6 code looks like this:
Private WithEvents objSerial As SerialIface
Private Sub objSerial_DataEvent()
'do something happy'
End Sub
Public Sub Class_Initialize()
Set objSerial = New SerialIface '<---this is the line that fails'
Call objSerial.Initialize '<--Initialize would trigger DataEvent, if it got this far'
End Sub
Well, normal API type functions seem to work (if I declare objSerial without the WithEvents keyword), but I can't get a "DataEvent" to work for life. It fails with the message "the object or class does not support a set of events."
At first I combined the two interfaces, but then C # complained that the DataEvent was not defined in the class. The way this is currently happening, I can fully view all the APIs and one event in the VB6 Object Explorer - everything looks as it is ... I just can't get it to work!
, - - , , .
Help!