2010-07-27 59 views
1

我有一個Windows服務,我需要在一臺機器上安裝並運行足夠長的時間發送日誌電子郵件,然後休眠24小時。如果我從Web客戶端調用服務方法,但它工作正常,但是當我從Windows服務調用它時,它每次都會失敗,並且錯誤信息不會給我任何特定的調查:作爲WCF服務的線程

通信對象,System.ServiceModel.Channels.ServiceChannel不能用於通信,因爲它處於Faulted狀態。

public partial class EDBDailyLogMailer : ServiceBase 
{ 
    Thread thread; 

    public EDBDailyLogMailer() 
    { 
     InitializeComponent(); 
     this.ServiceName = "EDB Daily Log Mailer"; 
    } 

    protected override void OnStart(string[] args) 
    { 
     try 
     { 
      thread = new Thread(MailLogDaily); 
      thread.Start(); 
     } 
     catch (Exception ex) 
     { 
      throw ex; 
     } 
    } 

    static void MailLogDaily() 
    { 
     while (true) 
     { 
      try 
      { 
       using (ApprovableFieldClient client = new ApprovableFieldClient()) 
        client.EmailEventLog(); 
       Thread.Sleep(86400000); 
      } 
      catch (Exception ex) 
      { 
       throw ex; 
      } 
     } 
    } 
} 

從其他地方調用時,EmailEventLog()中的代碼工作正常,所以我不會發布該代碼。這是我在App.config端點:

<system.serviceModel> 
<bindings> 
    <netTcpBinding> 
    <binding name="ExperienceServiceBinding" maxReceivedMessageSize="1048576" maxBufferSize="1048576"/> 
    </netTcpBinding> 
</bindings> 
<client> 
    <endpoint bindingConfiguration="ExperienceServiceBinding" address="net.tcp://bosvc01:1125/ApprovableFieldService" binding="netTcpBinding" contract="Ropes.Experience.Administration.Contracts.Services.IApprovableFieldService"> 
    <identity> 
     <servicePrincipalName value="[email protected]"/> 
    </identity> 
    </endpoint> 
</client> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="Ropes.Experience.Administration.Managers.ApprovableFieldManagerBehavior"> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

爲ApprovableFieldClient服務正在對bosvc01託管:1125

任何建議,將不勝感激。謝謝。

回答

1

已解決。我刪除了所有的嘗試/捕獲,並在錯誤消息

中給出了更多描述信息