title: WCF ChannelFactory casting interface to IClientChannel suspisious cast
body: <p>Using WCF ChannelFactory CreateChannel method of my custom interface - </p>
  
  <pre><code>ChannelFactory&lt;MyServiceInterface&gt; myFactory= 
  new ChannelFactory&lt;MyServiceInterface&gt;(binding,endpoint);
  
  MyServiceInterface clientInterface = myFactory.CreateChannel();
  </code></pre>
  
  <p>Reading a lot around the web, looks like I want to close my channel properly like - </p>
  
  <pre><code>private void ProperlyDisposeChannel(ICommunicationObject comObj)
          {
              bool success = false;
  
              if (comObj == null || comObj.State == CommunicationState.Closed)
              {
                  return;
              }
  
              try
              {
                  if (comObj.State != CommunicationState.Faulted)
                  {
                      comObj.Close();
                      success = true;
                  }
              }
              catch (Exception e)
              {
                  //optionally log exception
              }
              finally
              {
                  if (!success)
                  {
                      try
                      {
                          comObj.Abort();
                      }
                      catch (Exception e)
                      {
                          //do not retry to abort, optionally log
                      }
                  }
              }
          }
  </code></pre>
  
  <p>So I am trying to cast my channel to IClientChannel (or maybe IChannel), but VS is warning me - 
  Suspicious cast - there is no type in the solution that inherits both MyServiceInterface and System.ServiceModel.IClientChannel</p>
  
  <p>I was under the impression that the proxy returned by the factory automatically implements IClientChannel. Am I wrong? What is this warning about? And what should I cast my channel to? And maybe my ProperlyDisposeChannel method should accept IClientChannel instead of ICommunicationObject (I prefer ICOmmuminationObject bec it will work for other objects too)</p>
  
  <p>So I'm trying the following line which gives me the warning - </p>
  
  <pre><code>ProperlyDisposeChannel((IChannel)clientInterface);
  </code></pre>
  
  <p>or <code>ProperlyDisposeChannel((IClientChannel)clientInterface);</code></p>