Reading Configuration file

  • Thread starter Thread starter Paul Fi
  • Start date Start date
P

Paul Fi

I have this problem with .NET remoting:

my remote class is called RemoteHandler which implements an interface
called IEazyRemoting which has only one method to be implemented which
is [GetSum(int x,int y)] my server configuration file looks like this:

<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="Singleton"
type="RemoteHandler, RemoteObject"
objectUri="RemoteHandler" />
</service>
<channels>
<channel port="8085" ref="tcp" />
</channels>
</application>
</system.runtime.remoting>
</configuration>

The point of using an interface is that i only supply the client that
interface and not the concrete code of RemoteHandler so the Client
configuration file looks like this:

<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type="RemoteHandler, RemoteObject"
url="http://127.0.0.1:8085/RemoteHandler"
/>
</client>
<channels>
<channel ref="tcp" port="8086" />
</channels>
</application>
</system.runtime.remoting>
</configuration>

now my client code to start a remote object and call the public method
GetSum, is like this:

namespace Client
{
public class Client
{

public static void Main(string[] Args)
{
RemotingConfiguration.Configure("C:\\EazyRemoting\\Client\\Client.con
fig");
IEazyRemoting service = (IEazyRemoting)Activator.GetObject(
typeof(IEazyRemoting),
"tcp://127.0.0.1:8085/RemoteHandler");
if(service == null)
Console.WriteLine("here");
Console.WriteLine(service.GetProd(2,3));
Console.ReadLine();
}
}

}


so the problem here is that i mentioned the Url of the remote object
twice at the client side , one in the config file and the other is in
the client code what i want is not write the same url in the client code
but import the Url from the config file say by reading it from the
config file so how can i do that ? is there a better way of doing it
instead may be?
 
the problem here is that i mentioned the Url of the remote object
twice at the client side , one in the config file and the other is in
the client code what i want is not write the same url in the client code
but import the Url from the config file say by reading it from the
config file so how can i do that ? is there a better way of doing it
instead may be?

See if this article helps:

http://www.ingorammer.com/RemotingFAQ/USEINTERFACESWITHCONFIGFILES.html
 
Back
Top