Groups | Blog | Home
all groups > dotnet remoting > may 2005 >

dotnet remoting : Peer-to-peer - step 1


Jon Shemitz
5/5/2005 9:34:57 PM
I'm trying to write a very simple peer-to-peer WinForms app, using
..NET remoting.

In my form load, I register as a server:

TcpChannel Channel = new TcpChannel(Port);
ChannelServices.RegisterChannel(Channel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(Message),
URI,
WellKnownObjectMode.Singleton);

This seems to work as it should - the XP firewall asks if I want to
punch a hole for my app.

When the user selects a machine in the Network Neighborhood from a
dropdown (hey, I said this was very simple) I try to register as a
client:

object OtherMachine =
MachineNames.Items[MachineNames.SelectedIndex];

TcpChannel Channel = new TcpChannel();
ChannelServices.RegisterChannel(Channel);

string Request = String.Format("tcp://{0}:{1}/{2}",
OtherMachine, Port, URI);
RemoteInstance =
(Message)Activator.GetObject(typeof(Message), Request);

Problem is, when I run this, I get a "The channel 'tcp' is already
registered." RemotingException on the RegisterChannel call. If I
comment out the new tcpChannel and RegisterChannel lines, I get a
"Trying to create a proxy to an unbound type." RemotingException on
the GetObject call.

As you can probably tell, I'm VERY new to .NET remoting, and I'm sure
I'm missing something very obvious. (I sure hope it's not that I can't
simultaneously be a client and a server!)

--

Paul Wohlhart
5/6/2005 12:00:00 AM
[quoted text, click to view]

this is just like i do it

[quoted text, click to view]

i dont need the channel stuff at all at the client side.
i was looking around on msdn why you maybe should use it
but didn't find anything up to now.
Jon Shemitz
5/6/2005 11:39:22 AM
[quoted text, click to view]

It was just copy-and-paste from Ingo Rammer's book ....

--

AddThis Social Bookmark Button