I follow the sample of MSDN about remoting, it works some how
here is the code for them
with Client window form, when I click button to connect to server , my firewall ask me for permission, I allow and my client form (include listbox) appear "Hello Everybody!!!"
That worked !!!
But how to make something like "Function SayHello() was called!!!" appear in the listbox of Server window form ???
Thanks so much !!!
here is the code for them
VB.NET:
'RemotableType.vb
Imports System
Imports System.Runtime.Remoting
Public Class RemotableType
Inherits MarshalByRefObject
Public Function SayHello(ByVal Message As String) As String
Return Message
End Function
End Class
VB.NET:
'Listener.vb
Imports System
Imports System.Runtime.Remoting
Imports RemotableType
Public Class Listener
Private Sub Listener_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RemotingConfiguration.Configure("Listener.exe.config", False)
ListBox.Items.Add("Listening for requests ...")
End Sub
End Class
VB.NET:
'Client.vb
Imports System.Runtime.Remoting
Imports System
Imports RemotableType
Public Class Client
Dim remoteObject As New RemotableType.RemotableType
Private Sub Client_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Waiting for activating connection to server ...")
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
RemotingConfiguration.Configure("Client.exe.config", False)
ListBox1.Items.Add(remoteObject.SayHello("Hello Everybody!!!"))
End Sub
End Class
That worked !!!
But how to make something like "Function SayHello() was called!!!" appear in the listbox of Server window form ???
VB.NET:
'RemotableType.vb
Imports System
Imports System.Runtime.Remoting
Public Class RemotableType
Inherits MarshalByRefObject
Public Function SayHello(ByVal Message As String) As String
'What code I should use here ???
Return Message
End Function
End Class