Greetings,
I'm building a small sample application in order to better understand
..NET remoting. I have a graph object (my model) which lives on the
server side as a Singleton activated object. Clients can access this
object and, for example, add or remove a node.
When a client connects a new graph object is instatiated and on every
consecutive client connection (i.e. new Graph()) the reference to the
existing graph object is returned. Thus in order to "have" a graph
object a single client must have connected.
My question is if there is anyway to initialize the graph object on the
server side and then obtain a remote object reference to the existing
object on the client side? I have attempted this already but when the
clients call "new Graph()" a new remote graph object is created instead.
The code...
<server>
namespace Server
{
class App
{
Graph graph;
public App()
{
RemotingConfiguration.Configure("Server.exe.config");
// I want a client reference to this existing object
graph = new Graph();
graph.AddVertex("foo", 1, 2);
Console.WriteLine("Press enter to exit...");
Console.ReadLine();
}
static void Main(string[] args)
{
new App();
}
}
}
</server>
<server config>
<configuration>
<system.runtime.remoting>
<application name="Server">
<service>
<wellknown mode="Singleton"
type="Model.Graph, Graph"
objectUri="Graph" />
</service>
<channels>
<channel ref="tcp" port="2600" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
</server config>
<client>
....
RemotingConfiguration.Configure("Client.exe.config");
Graph = new Graph();
....
</client>
<client config>
<configuration>
<system.runtime.remoting>
<application name="Client">
<client>
<wellknown
type="Model.Graph, Graph"
url="tcp://localhost:2600/Graph" />
</client>
<channels>
<channel ref="tcp" />
</channels>
</application>
</system.runtime.remoting>
</configuration>
</client config>
Thanks in advance.
Cheers,
Emiel
--