How can you specify remoting parameters using Config files

Q

How can you specify remoting parameters using Config files ?

✍: Guest

A

Both remoting server and remoting client parameters can be provided through config files. Below is a sample of server config file which provides all remoting parameter values which we where providing through code.

<configuration>
<system.runtime.remoting>
<application name=”Server”>
<service>
<wellknown
mode=”SingleCall”
type=”Server.ClsServer, Server”
objectUri=”RemoteObject” />
</service>
<channels>
<channel ref=”tcp server” port=”9000" />
</channels>
</application>
</system.runtime.remoting>
</configuration>

Later this config file can be loaded using the following code.
RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ApplicationBase & “Server.config”)
Same way we also have client.config file for loading the client remoting parameters.

<configuration>
<system.runtime.remoting>
<application name=”Client”>
<client url=”tcp://localhost:9000/RemoteObject”>
<wellknown
type=”CommonInterface.Icommon, Icommon”
url = “tcp://localhost:9000/Server/RemoteObject”/>
</client>
<channels>
<channel ref=”tcp client” />
</channels>
</application>
</system.runtime.remoting>
</configuration>
client remoting can then load the configuration
 file by using :-
Dim IobjCommon As CommonInterFace.Icommon
Dim StrData As String
Dim objServiceEntries As WellKnownClientTypeEntry()
RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ApplicationBase
& “Client.config”)
objServiceEntries =
RemotingConfiguration.GetRegisteredWellKnownClientTypes()
IobjCommon = Activator.GetObject(GetType(Icommon),
objServiceEntries(0).ObjectUrl.ToString())
StrData = IobjCommon.GetValue()
Console.WriteLine(“ Serve side Data is “ & StrData)
Console.ReadLine()

2007-10-23, 4743👍, 0💬