我正在使用 .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()
        {

        }
    }
}

感谢您提供的任何帮助。

瓦卡诺

有帮助吗?

解决方案

作为 SingleCall 类型,将为客户端进行的每次调用创建 SampleObject。这对我来说意味着你的对象有问题,而你没有展示它的作用。您需要查看它对共享资源或锁的任何依赖关系。尝试在 SampleObject 的构造函数中编写一些调试,以查看远程调用进行到什么程度。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top