缺少频道接收器

时间:2011-05-15 16:20:21

标签: .net observer-pattern .net-remoting

您好我正在编写一个使用.NET Remoting和Observer模式的项目。

服务器:

BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 51317;
props["typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
props["name"] = "ServerChannel";
TcpChannel channel = new TcpChannel(props, clientProv, serverProv);

ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Tracker.Bl.Account.AccountManager), "AccountManager", WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Tracker.Bl.Account.AccountFVO), "AccountFVO", WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Tracker.Bl.Project.ProjectItemTracker), "ProjectItemTracker", WellKnownObjectMode.Singleton);

客户端:

this.thisUserId = userId;
this.instName = "Dev" + userId.ToString();
this.tracker = (ProjectItemTracker)Activator.GetObject(typeof(Tracker.Bl.Project.ProjectItemTracker), "tcp://localhost:51317/ProjectItemTracker");
this.Subscribe(this.tracker);

BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 51318;
props["typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
props["name"] = "ClientChannel";
TcpChannel channel = new TcpChannel(props, clientProv, serverProv);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownClientType(typeof(Tracker.Bl.Project.ProjectItemFVO), "ProjectItemFVO");

现在,当我使用“admin”进行更新时,应发送用户通知:

ProjectItemFVO loc = (ProjectItemFVO)Activator.GetObject(typeof(Tracker.Bl.Project.ProjectItemFVO), "tcp://localhost:51318/ProjectItemFVO");
        this.tracker.ProjectItemsChanged(loc);

但是,当处理ProjectItemsChanged事件时:

foreach (var observer in observers) {
    observer.OnNext(loc);
}

它给我一个错误说:这个远程代理没有通道接收器,这意味着服务器没有正在侦听的注册服务器通道,或者此应用程序没有合适的客户端通道与服务器通信。

我做错了什么?

0 个答案:

没有答案