开发者

Windows Service And Wcf

I am using WCF service in my Windows service in Onstart method my service call like this

    try
       {
    开发者_运维知识库       using (BackupUtilityWcfService.BackupUtilityClient oBackupUtilityClient =                 new BackupUtilityWcfService.BackupUtilityClient())
           {                  
                oBackupUtilityClient.ReadSnapshotMsmq();
                 oBackupUtilityClient.ReadReplicationMsmq();
                  oBackupUtilityClient.ReadReplicationCompleteMsmq();
             }
          }
       }
        catch
        {
       }

But When I call my WCF service i get this Error

Service cannot be started. System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace: at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)

What is wrong with this ?


Obviously the first remote call you make (ReadSnapshotMsmq) throws an exception on the service side, so the client channel becomes "Faulted". In this case you can not reuse the client channel to make further calls to your service.

You can place the remote function call in a try-catch block to catch the exception and gracefully close the faulted channel (or use a new one for subsequent calls).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜