Handling VB 6 events in C#
Posted on 2006-11-22
I want a C# application to handle events fired by a VB6 application. I have created a test app to demonstrate what I am trying to achieve but the C# app never picks up the VB 6 events.
I have the following test VB 6 app:
Public Event FileClosed(ByVal strFilename As String)
Public Function getFileName()
And the following C# test app that calls the above code:
public partial class Form1 : Form
public delegate void __Class1_FileClosedEventHandler(string strFilename);
Project1.Class1 cls = new Project1.Class1();
cls.FileClosed +=new Project1.__Class1_FileClosedEventHandler(cls_FileClosed);
public void cls_FileClosed(string strFilename)
private void button1_Click(object sender, EventArgs e)
Project1.Class1 obj = new Project1.Class1();
I can see that the VB app fires the event but it is not picked up by C#. Has anyone any ideas as to what I'm doing wrong?