2008-09-17 60 views
0

我正在使用.NET Remoting。我的服務器/主機是Windows服務。它有時會工作得很好,有時它會處理一個請求,然後它不再處理(直到我重新啓動它)。它是作爲Windows服務運行這裏是Windows服務的代碼:.NET Remoting服務器只處理一個請求

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() 
      { 

      } 
     } 
    } 

感謝您提供的任何幫助。

Vaccano

回答

1

爲SingleCall類型,您的SampleObject將爲每個調用客戶端,使創建。這表明你的對象有問題,而且你沒有顯示它的功能。您需要查看它對共享資源或鎖的任何依賴性。嘗試在SampleObject的構造函數中編寫一些調試以查看遠程調用得到多少。

相關問題