title: How to change State/Status in CRM 2013 using c#
body: <p>How do I change State and/or Status of an entity in CRM 2013 using C#? </p>
  
  <p>Neither CRM 2011's SetStateRequest nor the earlier SetStateDynamicEntityRequest are being recognized.
  Searching online didn't seem to help either... Am I missing a namespace or something?  </p>
  
  <p>Thanks in advance</p>
  
  <p>Namespaces:   </p>
  
  <pre><code>using System;  
  using System.Collections;  
  using System.Collections.Generic;  
  using System.Linq;  
  using System.Text;  
  using System.Net;  
  using Microsoft.Xrm.Sdk;  
  using Microsoft.Xrm.Sdk.Client;  
  using Microsoft.Xrm.Sdk.Query;  
  using Microsoft.Xrm.Sdk.Discovery;  
  using Microsoft.Xrm.Sdk.Messages;  
  using System.ServiceModel;  
  using System.ServiceModel.Description;  
  using System.Web.Services.Protocols;  
  </code></pre>
  
  <p>The function:</p>
  
  <pre><code>private void changeUserStatus(Guid userId, IOrganizationService service, int state)  
  {  
      SetStateRequest setStateRequest = new SetStateRequest  
      {  
          EntityMoniker = new EntityReference("systemuser", userId),  
          State = new OptionSetValue(state),  
          Status = new OptionSetValue(-1),  
      };  
      service.Execute(setStateRequest);  
  }  
  </code></pre>
  
  <p><strong>IMPORTANT:</strong> My SetStateRequest is NOT recognized by visual studio 2012, so unlike the above example it's not highlighted and actually red underlined with the "the type or namespace not found" message displayed when hovering  </p>
  
  <p>Edit: I see the question got downvoted and I'm sorry if I'm missing something but I really have no more information to provide apart from the fact that I've spent 4 hours yesterday looking for this online (including stackoverflow) without any avail. I may be using the wrong search criteria or looking in the wrong places, but if that's the case could anyone at least point me in the right direction? I'm a beginner on all of this (both stackoverflow and crm2013) and I'm kind of stuck on this. Thanks again</p>