louiserutherford
asked on
Handling VB 6 events in C#
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()
RaiseEvent FileClosed("C:\Test")
End Function
And the following C# test app that calls the above code:
public partial class Form1 : Form
{
public delegate void __Class1_FileClosedEventHa ndler(stri ng strFilename);
public Form1()
{
InitializeComponent();
Project1.Class1 cls = new Project1.Class1();
cls.FileClosed +=new Project1.__Class1_FileClos edEventHan dler(cls_F ileClosed) ;
}
public void cls_FileClosed(string strFilename)
{
MessageBox.Show(strFilenam e);
}
private void button1_Click(object sender, EventArgs e)
{
Project1.Class1 obj = new Project1.Class1();
obj.getFileName();
}
}
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?
Thanks
I have the following test VB 6 app:
Public Event FileClosed(ByVal strFilename As String)
Public Function getFileName()
RaiseEvent FileClosed("C:\Test")
End Function
And the following C# test app that calls the above code:
public partial class Form1 : Form
{
public delegate void __Class1_FileClosedEventHa
public Form1()
{
InitializeComponent();
Project1.Class1 cls = new Project1.Class1();
cls.FileClosed +=new Project1.__Class1_FileClos
}
public void cls_FileClosed(string strFilename)
{
MessageBox.Show(strFilenam
}
private void button1_Click(object sender, EventArgs e)
{
Project1.Class1 obj = new Project1.Class1();
obj.getFileName();
}
}
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?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER