无法在 ASP.NET 中使用 WCF NetPeerTcpBinding?

发布于 08-22 07:45 字数 795 浏览 9 评论 0原文

我为网络场编写应用程序,我想在服务器应用程序之间创建一个简单的对等网络,以便它们可以相互传递消息。例如,在删除缓存项时进行协调,或者增加共享计数器以获得关键统计数据的更好共享视图。

但显然这是不可能的。我的点对点代码在控制台应用程序中完美运行,但是当我将代码添加到 ASP.NET 网站时,出现以下错误:

当前上下文不支持系统事件通知。例如,服务器进程可能不支持全局系统事件通知。

[InvalidOperationException: System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10259418
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +539
   // My code here where I call the proxy object's method to start the WCF call

嗯,为什么不呢?看来这个功能非常有用啊!

有什么办法可以解决这个问题吗?

I write applications for web farms and I wanted to create a simple peer network between server applications so they could pass messages to each other. For example, to coordinate when dropping cache items, or to increment a shared counter to have a better shared view of a crucial statistic.

But apparently this isn't possible. I had peer-to-peer code working perfectly in a console application, but when I added the code to an ASP.NET website I got the following error:

System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications.

[InvalidOperationException: System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +10259418
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +539
   // My code here where I call the proxy object's method to start the WCF call

Um, why not? It seems like this would be supremely useful!

Is there any way to get around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野侃2024-08-29 07:45:40

您的服务运行在哪个版本的 IIS 上(假设是 IIS)? IIS 6 比 IIS 7 有相当多的限制 - 它仅支持 HTTP 激活。同样,如果您尝试从 IIS 6 中启动对等客户端,它可能会因同样的原因而被阻止 - IIS 无法将响应定向到正确的工作进程。

您始终可以将该服务实现为 Web 服务器上的 Windows 服务,并使用命名管道与 ASP.NET 站点进行通信。 (Windows 服务将托管一个对等端点和一个命名管道端点,站点将使用命名管道客户端。该服务将使用 [ServiceBehavior] 属性作为单个实例运行。

What version of IIS is your service running on (assuming IIS)? IIS 6 is quite a bit more limited than IIS 7 - it only supports HTTP activation. Likewise, if you're trying to start a peer-to-peer client from within IIS 6, it may be blocked for the same reason - IIS can't direct responses to the correct worker process.

You could always implement the service as a Windows service on the web server, and use named pipes to communicate with your ASP.NET site. (The Windows service would host a peer-to-peer endpoint and a named-pipe endpoint, and the site would use a named-pipe client. The service would run as a single instance using the [ServiceBehavior] attribute.

梦毁影碎の2024-08-29 07:45:40

我不确定这是否可能,因为绑定保存其上下文的方式。

我建议使用普通的 http wcf 服务并在配置数据库中注册每个主机,甚至使用主题并发布 Web 服务器需要处理的事件。

I am not sure this is possible because of the way the binding holds its context.

I would suggest having a normal http wcf service and register each host in a configuration database, or even use a topic and post events that web server needs to process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文