Hi,
Can someone please tell me how I would convert the code below to use a config file instead. I've looked at loads of examples on the web but can't quite get it to work:
I can't figure out how to instantiate the "server" variable using a config file so that MessageBox.Show(Server.GetMessage) doesn't throw an error....
Thanks
Can someone please tell me how I would convert the code below to use a config file instead. I've looked at loads of examples on the web but can't quite get it to work:
VB.NET:
Imports System.Runtime.Remoting
Imports system.Runtime.Remoting.Channels
Public Class frmClient
Private Server As IRemotingInterface.IRemoteInterface
Private Sub cmdHelloWorld_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdHelloWorld.Click
MessageBox.Show(Server.GetMessage)
End Sub
Private Sub InitRemoting()
Dim Channel As Channels.Tcp.TcpChannel
Dim serverProv As Channels.BinaryServerFormatterSinkProvider
Dim clientProv As Channels.BinaryClientFormatterSinkProvider
Dim props As IDictionary = New Hashtable
serverProv = New Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider
clientProv = New Channels.BinaryClientFormatterSinkProvider
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
props("port") = 0
Channel = New Channels.Tcp.TcpChannel(props, clientProv, serverProv)
ChannelServices.RegisterChannel(Channel, False)
Try
Server = CType(Activator.GetObject(GetType(IRemotingInterface.IRemoteInterface), _
"tcp://localhost:9000/RemotingExample"), IRemotingInterface.IRemoteInterface)
If Server Is Nothing Then
MsgBox("Unable to connect to remoting service!", MsgBoxStyle.Exclamation)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub frmClient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
InitRemoting()
End Sub
End Class
Thanks
Last edited by a moderator: