title: CA2202, how to solve this case
body: <p>Can anybody tell me how to remove all CA2202 warnings from the following code?     </p>
  
  <pre><code>public static byte[] Encrypt(string data, byte[] key, byte[] iv)
  {
      using(MemoryStream memoryStream = new MemoryStream())
      {
          using (DESCryptoServiceProvider cryptograph = new DESCryptoServiceProvider())
          {
              using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptograph.CreateEncryptor(key, iv), CryptoStreamMode.Write))
              {
                  using(StreamWriter streamWriter = new StreamWriter(cryptoStream))
                  {
                      streamWriter.Write(data);
                  }
              }
          }
          return memoryStream.ToArray();
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Warning   7   CA2202 : Microsoft.Usage : Object 'cryptoStream' can be disposed more than once in method 'CryptoServices.Encrypt(string, byte[], byte[])'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 34   </p>
    
    <p>Warning   8   CA2202 : Microsoft.Usage : Object 'memoryStream' can be disposed more than once in method 'CryptoServices.Encrypt(string, byte[], byte[])'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 34, 37    </p>
  </blockquote>
  
  <p>You need Visual Studio Code Analysis to see these warnings (these are not c# compiler warnings).</p>