CA 2202,如何解决这个案子有人能告诉我如何从下面的代码中删除所有CA 2202警告吗?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();
}}警告7 CA 2202:Microsoft.Usage:Object‘crypStream’可以在方法‘CryptoServices.Encrypt(字符串、字节[])中多次释放。若要避免生成System.ObjectDisposedException,不应对象调用Dispose超过一次。:行:34警告8 CA 2202:Microsoft.Usage:Object‘MemyStream’可以在方法‘CryptoServices.Encrypt(字符串、字节[])中多次释放。若要避免生成System.ObjectDisposedException,不应对象调用Dispose超过一次。:行:34、37您需要VisualStudio代码分析来查看这些警告(这些警告不是c#编译器警告)。
3 回答
UYOU
TA贡献1878条经验 获得超4个赞
- 3 回答
- 0 关注
- 606 浏览
添加回答
举报
0/150
提交
取消