469,903 Members | 1,911 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Handling VB6 (ActiveX) events in C# app

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(cla ss_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
Nov 16 '05 #1
2 5187
On 07 Jun 2004 01:57, Bill wrote:
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:
<snip>oClass = new Project1.Class1Class();
oClass.SometingHappened += new
Project1.__Class1_SometingHappenedEventHandler(cl ass_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.

--
Simon Smith
simon dot s at ghytred dot com


Nov 16 '05 #2
>
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
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sagaert Johan | last post: by
reply views Thread by Kevin Ortman | last post: by
1 post views Thread by Felipe Garcia | last post: by
reply views Thread by Itchy Ferret | last post: by
1 post views Thread by Jialiang Ge [MSFT] | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.