What is the best workaround for the WCF client `using` block issue?

前端 未结 26 1599
余生分开走
余生分开走 2020-11-22 00:03

I like instantiating my WCF service clients within a using block as it\'s pretty much the standard way to use resources that implement IDisposable:

26条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 00:29

    You could also use a DynamicProxy to extend the Dispose() method. This way you could do something like:

    using (var wrapperdProxy = new Proxy())
    {
       // Do whatever and dispose of Proxy will be called and work properly.
    }
    

提交回复
热议问题