To huangsuipeng(hsp|I love foxpig):应该是一个端口,一个是C、一个是S,C用的临时端口可以不管,但调用S的端口必须是S的9089端口。
这个贴太久没节了,我已经实现。找时间整理一下Demo贴上来。谢谢诸位。
可以的,你注册通道的时候不要指定是Client OR Server用的通道就行了 比如用:TcpChannel channel = new TcpChannel(1234); 而不是用:TcpServerChannel channel = new TcpServerChannel( tcpProp, new BinaryServerFormatterSinkProvider() );
请问具体如何做?我的代码运行产生异常。
TcpServerChannel channel = new TcpServerChannel(9089);
ChannelServices.RegisterChannel(channel);//注册服务类型
RemotingConfiguration.RegisterActivatedServiceType(typeof(RemoteObj));
//创建远程对象
object[] param = {"param"};
object[] attrs = {new UrlAttribute("tcp://172.16.1.19:9089")};
RemoteObj obj= (RemoteObj ) Activator.CreateInstance(typeof(RemoteObj), param, attrs);//%在%处抛出异常:"调用的目标发生了异常。"
——异常具体内容是:{"试图连接到远程激活器时失败,异常为 System.Runtime.Remoting.RemotingException: 信道 tcp 已注册。
比如用:TcpChannel channel = new TcpChannel(1234);
而不是用:TcpServerChannel channel = new TcpServerChannel(
tcpProp,
new BinaryServerFormatterSinkProvider()
);