How to get rid of System.ServiceModel.ClientBase <TChannel>?

I use a class that extends ClientBase <>:

interface IService {}
class MyServiceClient : ClientBase<IService> {}

The problem I am facing is that FxCop complains that a class with MyServiceClient as a member variable should also implement IDisposable and recycle MyServiceClient.

ClientBase has an explicit implementation of Dispose (), which means that the simple MyServiceClient.Dispose () does not compile. I must explicitly point to IDisposable. Why is this? Is this a signal that I should not use Dispose ()? Should I use Close () instead?

+3
source share
2 answers

Close Dispose - ? , Close Dispose ​​ . - - (usage), Close Dispose. , Close.

+4

, . :

using (var someClient = new SomeClient(_netTcpBinding,_endpointAddress))
{
    return someClient.SomeMethod();
}

cmd netstat -a -n -p TCP, enter image description here

, http://sahilmalik.blogspot.ru/2005/11/sockets-and-timewait.html , http://marcgravell.blogspot.ru/2008/11/dontdontuse-using.html

0

Source: https://habr.com/ru/post/1791320/


All Articles