简体   繁体   English

WCF故障状态

[英]WCF Faulted State

How can a WCF CommunicationObject transition to a faulted state: I created a WCF library in Visual Studio, deployed it into IIS, inside it i have two methods: WCF CommunicationObject如何过渡到故障状态:我在Visual Studio中创建了一个WCF库,将其部署到IIS中,在其中有两种方法:

    public string GetData(int value)
    {
        throw new FaultException(value.ToString());
    }

    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
        throw new TestException();
    }

From the client, i simply call these two methods over and over again, however, the CommunicationObjectFaultedException is not thrown at any time. 从客户端,我只是简单地一遍又一遍地调用这两个方法,但是, CommunicationObjectFaultedException不会在任何时候抛出。

I read in an article WCF error handling and some best practices that non-FaultExceptions are converted by default "automatically" to a FaultException. 我读了一篇WCF错误处理和一些最佳做法的文章,其中默认情况下将非FaultException自动“自动”转换为FaultException。 If this is right, then when and how does the WCF client's communication object become in a faulted state? 如果正确,那么WCF客户端的通信对象何时以及如何变为故障状态?

One other thing, does anybody know any MSDN reference that confirms that FaultException is the best way to make sure the WCF communication object does not transition into Faulted state . 另一件事,是否有人知道任何MSDN参考,该参考确认FaultException是确保WCF通信对象不会转换为Faulted state的最佳方法。

The channel will be on a faulted state if you are using a session (ie a binding that supports session) and a call to a method raises an exception that is not handled. 如果您正在使用会话(例如,支持会话的绑定),并且对方法的调用引发了未处理的异常,则通道将处于故障状态。

Another way you can get into a faulted state is the session timing out while the channel is open. 进入故障状态的另一种方法是在通道打开时会话超时。

It is the channel that is in a faulted state, not the service 处于故障状态的是通道 ,而不是服务

Understanding State Changes in WCF 了解WCF中的状态变化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM