I am a C# programmer and have made a C# library for handling a tcp/ip chat. Now I have the necessity to use it from a Server VB Winform program. I am pretty sure that this is an easy solution problem but I have been struggling for days. So in the C# I have that class:
public class AsynchronousServer
{
public AsynchronousServer()
{
}
public delegate void ChangedEventHandler(string strMessage);
public static event ChangedEventHandler OnNotification;
public static event ChangedEventHandler OnAnswerReceived;
...
}
Now I have to focus on the server program: if that VB program would have been in C# I would have written the code below for connecting the server on a button click
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnStart_Click(object sender, RoutedEventArgs e)
{
AsynchronousServer.OnNotification += AsynchronousServer_OnNotification;
AsynchronousServer.OnAnswerReceived += AsynchronousServer_OnAnswerReceived;
AsynchronousServer.StartServer(tbxIpAddress.Text,tbxPort.Text);
}
The same program in VB:
Imports SocketLibrary
Public Class Form1
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
AsynchronousServer.OnNotification <--- member not present
AsynchronousServer.OnAnswerReceived <--- member not present
AsynchronousServer.StartServer(tbxIpAddress.Text, tbxPort.Text);<-----OK
End Sub
End Class
the problem is that the member AsynchronousServer.OnNotification is not present at all so I can't add the event. I am aware that I might have to add the WithEvents keyword but try as I might I couldn't succed.
In short I have to connect that VB winform program to a C# library event which I can't see from my VB class.
Thanks for any help
Patrick