hello, I have followed a tutorial on how to expose a class method over the net using net remoting.
All is working fine. I have 2 apps, one acting as a server:
and the other acting as a client:Code:TcpChannel channel = new TcpChannel(12345); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(myclass), "mymethod", WellKnownObjectMode.Singleton );
I then tried to combine this two snippets into a single chat application. I wanted to run two instances of it and let them both act as client and server at the same time.Code:TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan); obj = (myclass) Activator.GetObject( typeof(myclass), "tcp://localhost:12345/mymethod" );
InstanceA calls mymethod on InstanceB
InstanceB calls mymethod on InstanceA
Unfortunately I get an error when I try to register the client channel after I registered the server channel. ie I get an error on the line in red:
what should I do? Is what I'm trying to do possibile in first place?Code:TcpChannel channel = new TcpChannel(12345); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(myclass), "mymethod", WellKnownObjectMode.Singleton ); TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan); obj = (myclass) Activator.GetObject( typeof(myclass), "tcp://localhost:12345/mymethod" );
I cannot provide the exception description because the debugger just says "Application has generated an exception that could not be handled".
Many thanks in advance ^^




Reply With Quote