ICommunicationObject上的Close方法可以抛出两种类型的异常作为MSDN轮廓
here.我明白为什么Close方法可以抛出这些异常,但我不明白的是为什么服务代理上的Dispose方法调用Close方法而不使用试试吧.你的Dispose方法不是你想要的地方,确保你不会抛出任何异常?
解决方法
它似乎是.NET代码中的常见设计模式.这是
Framework design guidelines的引文
Consider providing method Close(),in addition to the Dispose(),if close is standard terminology in the area. When doing so,it is important that you make the Close implementation identical to Dispose …
这是一个blog post,您可以在其中找到此System.ServiceModel.ClientBase设计问题的解决方法