need help with config file
i have a remote object in the server side which implements an interface that declared in a dll.
something like that:
DLL-
interface Iremote{..}
Server Side-
class RemoteClass implements Iremote{..}
Client Side-
//connect to server
//Activator.GetObject --> typeof Iremote!!
till now everything is ok
now im trying to put it in a configuration file:
<service>
<wellknown mode="Singleton"
type="ServerSide.RemoteClass ,ServerSide" />
</service>
but what should i write in the "type"??
i know ServerSide.RemoteClass is wrong,
the type supposed to be - new RemoteClass().GetType()
but how to write that in the config?
thanks in advanced
Re: need help with config file
I assume that the config file is on the client side. So since ServerSide.RemoteClass implements the interface IRemote you can simply write:
<service>
<wellknown mode="Singleton"
type="<IRemoteNamespace>.IRemote, <IRemoteNamespace>" />
</service>
Where <IRemoteNamespace> is the namespace of the IRemote interface.
Hope this works for you.
Mario
Re: need help with config file
actually the config file is on the server side
so i tried that-
<service>
<wellknown mode="Singleton" type="IRemoteNamespace.IRemote,IRemoteNamespace" objectUri="Server.rem"/>
</service>
but its not working.
what else can it be?
thanks
Re: need help with config file
Re: need help with config file
Don't know any specifics but the following links may give you more background information
.NET Remoting FAQ
(Maybe) in particular: HOWTO: Use Interface-based remote objects with config files
Re: need help with config file
thanks but id didnt found there what i need...
any more ideas?
Re: need help with config file
I for one find it diificult to debug code I cannot see...
Any chance you can post the client, server and shared library code, as well as the client and server config files?
Re: need help with config file
ok, here is the code-
//class library
public interface IRemoteObject
{
Guid register();
}
//client side(inside main)
TcpChannel chan=new TcpChannel();
ChannelServices.RegisterChannel(chan);
IRemoteObject obj=(Library.IRemoteObject)Activator.GetObject(typeof(Library.IRemoteObject),"tcp://localhost:8085/Server");
Guid id=obj.register();
//server side(inside main)
RemotingConfiguration.Configure("ServerSide.exe.config");
//server side (config)
<system.runtime.remoting>
<application>
<channels>
<channel name="channel1" ref="tcp" port="8085"></channel>
</channels>
<service>
<wellknown mode="Singleton" type="ServerSide.TasksManagement,ServerSide" objectUri="ServerSide.rem"/>
</service>
</application>
</system.runtime.remoting>
//server side(remote object)
public class TasksManagement: MarshalByRefObject,IRemoteObject
{
public Guid register()
{ return System.Guid.NewGuid();
}
}
Re: need help with config file
Quick guess: Shouldn't "tcp://localhost:8085/Server" match your server config ie. "tcp//localhost:8055/ServerSide.rem" ?
Re: need help with config file
ok so i changed it in the server side to-
IRemoteObject obj=(Library.IRemoteObject)Activator.GetObject(typeof(Library.IRemoteObject),"tcp://localhost:8085/ServerSide/TasksManagement.rem");
and in he config on the server side i wrote-
<wellknown mode="Singleton" type="ServerSide.TasksManagement,ServerSide" objectUri="TasksManagement.rem"/>
but it still not working...
Re: need help with config file
This is still wrong:
"tcp://localhost:8085/ServerSide/TasksManagement.rem"
Should be:
"tcp://localhost:8085/TasksManagement.rem"
This may still not work but it definitely won't work with such obvious mistakes.
Re: need help with config file
PS. I assume your server code actually is
Code:
RemotingConfiguration.Configure("ServerSide.exe.config");
Console.ReadLine();
Re: need help with config file
Re: need help with config file
Re: need help with config file
3 Attachment(s)
Re: need help with config file
I took your code and it works fine!!!
Attached are the files I used in three separate assemblies; ServerSide, Library and Client respectively.
Below is the ServerSide config.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel name="channel1" ref="tcp" port="8085"></channel>
</channels>
<service>
<wellknown mode="Singleton" type="ServerSide.TasksManagement, ServerSide" objectUri="TaskManagement.rem" />
</service>
</application>
</system.runtime.remoting>
</configuration>
Re: need help with config file
well..after i created a new project and deal with RegServer it worked!!
so thanks a lot for the help :)