0

我正在使用 .NET 远程处理。我的服务器/主机是 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()
        {

        }
    }
}

感谢您提供的任何帮助。

瓦卡诺

4

1 回答 1

1

作为 SingleCall 类型,您的 SampleObject 将为客户端进行的每次调用创建。这向我表明您的对象有问题,并且您没有显示它的作用。您需要查看它对共享资源或锁的任何依赖关系。尝试在 SampleObject 的构造函数中编写一些调试程序,以查看远程调用能走多远。

于 2008-09-17T16:42:45.813 回答