问个关于remoting的错误,请高手指点
最近在写一个基于remoting的聊天程序,服务器端代码如下:
BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props[ "port "] = 8080;
TcpChannel tc = new TcpChannel(props, null, provider);
ChannelServices.RegisterChannel(tc, false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ChatRoom), "ChatRoomURL ", WellKnownObjectMode.Singleton);
客户端代码如下:
TcpChannel tc = new TcpChannel();
ChannelServices.RegisterChannel(tc);
ChatRoom m_ChatRoom = (ChatRoom)Activator.GetObject(typeof(ChatRoom)
, "tcp://localhost:8080/ChatRoomURL ");
运行中只要一调用m_ChatRoom中的方法或者事件,就会出现如下异常:
Cannot load type 'WinRemotingAppClient.ChatRoom '
ChatRoom 是我写的一个类,继承 MarshalByRefObject
请教高手,这个异常是什么意思?该如何解决,万分感谢!
------解决方案--------------------服务端客户端两边都部署了ChatRoom 没??
你其实还可以单做一个程序集,里面只包括一个接口,ChatRoom 继承于这个借口,客户端引用这接口
------解决方案--------------------props[ "port "] = 8080;
props[ "name" ] = "mytcp";
加上下面这句试试.