title: WCF Service Client Lifetime
body: <p>I have a WPF appliction that uses WCF services to make calls to the server.</p>
  
  <p>I use this property in my code to access the service</p>
  
  <pre><code>private static IProjectWcfService ProjectService
  {
      get
      {
          _projectServiceFactory = new ProjectWcfServiceFactory();
          return _projectServiceFactory.Create();
      }
  }
  </code></pre>
  
  <p>The Create on the factory looks like this</p>
  
  <pre><code>    public IProjectWcfService Create()
      {
          _serviceClient = new ProjectWcfServiceClient();
  
          //ToDo: Need some way of saving username and password 
          _serviceClient.ClientCredentials.UserName.UserName = "MyUsername";
          _serviceClient.ClientCredentials.UserName.Password = "MyPassword";
  
          return _serviceClient;
      }
  </code></pre>
  
  <p>To access the service methods I use somethingn like the following.</p>
  
  <pre><code>ProjectService.Save(dto);
  </code></pre>
  
  <p>Is this a good approach for what I am trying to do?  I am getting an errorthat I can't track down that I think may be realted to having too many service client connections open (is this possible?) notice I never close the service client or reuse it.</p>
  
  <p>What would the best practice for WCF service client's be for WPF calling?</p>
  
  <p>Thanks in advance...</p>