您现在的位置是:首页
>
调用服务失败是什么 不要在using语句中调用WCF服务
不要在u i g语句中调用WCF服务 如果你调用WCF服务时 像下面的代码这样在u i g语句中进行调用 需要注意一个问题 u i g C log WcfClie t clie t = ew C

不要在using语句中调用WCF服务
如果你调用WCF服务时 像下面的代码这样在using语句中进行调用 需要注意一个问题
using (CnblogsWcfClient client = new CnblogsWcfClient()) { client Say( Hello ! ); }上面这段代码看上去没问题 CnblogsWcfClient是一个自动生成的WCF客户端代理 继承自System ServiceModel ClientBase using语句结束时 会调用ClientBase实现的System IDisposable Dispose接口 实际就是调用ClientBase的Close()方法 用 NET Refector打开C:WindowsMicrosoft NETFrameworkv System ServiceModel dll 可以看到这样的代码 见下图
很赞哦! (1109)