Domanda

Sto utilizzando i servizi remoti .NET.Il mio server/hoster è un servizio Windows.A volte funzionerà perfettamente e altre volte elaborerà una richiesta e quindi non la elaborerà più (finché non la riavvio).Funziona come un servizio Windows Ecco il codice del servizio 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()
        {

        }
    }
}

Grazie per l'aiuto offerto.

Vaccano

È stato utile?

Soluzione

come tipo SingleCall, il tuo SampleObject verrà creato per ogni chiamata effettuata dal client.Questo mi suggerisce che il tuo oggetto è colpevole e non mostri cosa fa.È necessario esaminare eventuali dipendenze che ha su risorse condivise o blocchi.Prova a scrivere qualche debug nel costruttore di SampleObject per vedere fino a che punto arriva la chiamata remota.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top