Handling VB6 (ActiveX) events in C# app

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

I have a VB6 ActiveX EXE app that generates events that I would like
to handle in a C# application. The events in the VB app are defined
like:

Public Event SometingHappened(what As String)

and raised like so:

Public Sub EventNotification(ByVal what As String)
RaiseEvent SometingHappened(what)
End Sub

in the C# app I create the VB ActiveX object and add the C#
eventhandler:

oClass = new Project1.Class1Class();
oClass.SometingHappened += new
Project1.__Class1_SometingHappenedEventHandler(class_event_handler);

and the eventhandler looks like:

private void class_event_handler(ref string what)
{
MessageBox.Show(what);
}

Everything builds OK in VS and when I run it and generate the event in
the VB ActiveX EXE nothing happens in the C# app. The event doesn't
seem to trigger the C# eventhandler. Any suggestions? or good examples
of trying to handle this situation?

Thanks Bill
 
I have a VB6 ActiveX EXE app that generates events that I would like
to handle in a C# application. The events in the VB app are defined
like:
oClass = new Project1.Class1Class();
oClass.SometingHappened += new
Project1.__Class1_SometingHappenedEventHandler(class_event_handler);

and the eventhandler looks like:

private void class_event_handler(ref string what)
{
MessageBox.Show(what);
}

Everything builds OK in VS and when I run it and generate the event in
the VB ActiveX EXE nothing happens in the C# app. The event doesn't
seem to trigger the C# eventhandler. Any suggestions? or good examples
of trying to handle this situation?


Do you still have the reference to the VB8 object - i.e. does oClass still
exist? If not, then this can happen easily.
 
Do you still have the reference to the VB8 object - i.e. does oClass still
exist? If not, then this can happen easily.

Yes.

To give a little more background...
I created a simple VB6 ActiveX.exe form with one button to generate
the event that I'm trying to trap in the C# application. In the button
click event handler I simply call EventNotification("test") which
raises the event (RaiseEvent SometingHappened(what)).

The C# application is a simple form with one button whose click
eventhandler calls a method on oClass to display a msgbox (in the VB6
app). That works fine! So I know that that object exists and works
properly calling from the C# app to the VB6 ActiveX app.

The only problem is that the events in the VB6 app are not triggering
the C# eventhandler.

Thanks Bill
 
Back
Top