.NET Remoting Server仅处理一个请求
时间:2020-03-05 18:59:19 来源:igfitidea点击:
我正在使用.NET Remoting。我的服务器/主机是Windows服务。有时它将正常工作,而其他时候它将处理一个请求,然后不再处理(直到我重新启动它)。它作为Windows服务运行。这是Windows服务中的代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.ServiceProcess; using System.Text; using Remoting; namespace CreateReview { public partial class Service1 : ServiceBase { public Service1() { InitializeComponent(); } readonly TcpChannel channel = new TcpChannel(8180); protected override void OnStart(string[] args) { // Create an instance of a channel ChannelServices.RegisterChannel(channel, false); // Register as an available service with the name HelloWorld RemotingConfiguration.RegisterWellKnownServiceType( typeof(SampleObject), "SetupReview", WellKnownObjectMode.SingleCall); } protected override void OnStop() { } } }
感谢我们提供的任何帮助。
瓦卡诺
解决方案
回答
作为SingleCall类型,将为客户端进行的每个调用创建SampleObject。这向我表明对象有问题,并且我们没有显示它的作用。我们需要查看它对共享资源orlock的任何依赖性。尝试在SampleObject的构造函数中编写一些调试信息,以查看远程调用的效果。