加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – WCF由于处于故障状态,无法用于通信

发布时间:2020-12-15 03:55:13 所属栏目:百科 来源:网络整理
导读:当我尝试使用webservice我得到以下异常.我的主要问题是这个异常何时发生?在服务器或客户端?错误在哪里?服务器是否为广泛的故障引发这种错误? 我自己做了一些改变,似乎工作 它实际上现在工作.我删除了使用并在服务客户端添加了一些清理. if (Service != n
当我尝试使用webservice我得到以下异常.我的主要问题是这个异常何时发生?在服务器或客户端?错误在哪里?服务器是否为广泛的故障引发这种错误?

我自己做了一些改变,似乎工作

它实际上现在工作.我删除了使用并在服务客户端添加了一些清理.

if (Service != null && Service.State != CommunicationState.Faulted)
                {
                    success = true;
                    Service.Close();
                }

            }
            catch (Exception ex)
            {
                msg = "Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace;
            }
            finally{
                if (!success)
                {
                    if (Service != null) Service.Abort();
                }
            }

这是例外:

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)

Exception rethrown at [0]: 
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
 at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Close()
at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose()
at bNet.Services.Customers.Cres.Helios.ServiceForm.Send(ServiceFormAction task) in C:bNetProjectsbNet Web ToolsSolution rootbNet.ServicesCustomersCresHeliosServiceForm.cs:line 99
at bNet.Web.Sites.Public.Customers.Cres.ServiceSkjema.Units.Page.ServiceFormControl.SubmitFormClick(Object sender,EventArgs e) in C:bNetProjectsbNet Web ToolsSolution rootbNet.Web.Sites.PublicCustomersCresServiceSkjemaUnitsPageServiceFormControl.ascx.cs:line 192
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

解决方法

故障状态表示服务器端出现意外异常.在以前的通话中.

你也应该在客户端遇到异常,也许你的代码忽略它?

您可以通过重新打开连接来解决它.但似乎你需要更好的错误处理.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读