WCF 4关闭客户端代理
在过去(.net Framework 3.5),我们需要小心关闭 WCF 客户端代理。
在 WCF 4 中,客户端无法执行“关闭”操作。但它在代理内部可用。
public class ServiceProxy : System.ServiceModel.ClientBase<IService>, ILoginService
{
}
不再需要关闭客户端代理吗?或者说我们该怎么做呢?
In the old days (.net framework 3.5) we need to be careful to close the WCF client proxies.
In WCF 4 the Close is not available from the client. But it is available inside the proxy.
public class ServiceProxy : System.ServiceModel.ClientBase<IService>, ILoginService
{
}
Is closing the client proxy no longer required? Or how do we do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自: http://geekswithblogs.net/SudheersBlog/archive/2009/09 /01/134430.aspx
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/b95b91c7-d498-446c-b38f-ef132989c154
http://geekswithblogs.net/marcel/archive/2007/05/01/112159.aspx
建议的最佳实践是在客户端使用完代理后始终关闭代理,因为关闭代理会终止与服务的会话并关闭连接。
或者,您可以使用代理的 Dispose() 方法来关闭它。 Dispose()方法的优点是即使遇到异常也可以使用using语句来调用它
检查
http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the -right-way.aspx
http://geekswithblogs.net /bcaraway/archive/2008/07/06/123622.aspx
From: http://geekswithblogs.net/SudheersBlog/archive/2009/09/01/134430.aspx
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/b95b91c7-d498-446c-b38f-ef132989c154
http://geekswithblogs.net/marcel/archive/2007/05/01/112159.aspx
It is a recommended best practice to always close the proxy when the client is done using it, because closing the proxy terminates the session with the service and closes the connection.
Alternatively, you can use the Dispose() method of the proxy to close it. The advantage of the Dispose() method is that you can use the using statement to call it even in the face of exceptions
check
http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx
http://geekswithblogs.net/bcaraway/archive/2008/07/06/123622.aspx