开发者

How do I manually Dispose RSACryptoServiceProvider?

I have read on MSDN(see Important note) that RSACryptoServiceProvider must be disposed. They give the example:

using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())

Now I'm trying to include RSACryptoServiceProvider into MyClass making use of it in several Methods. With this setup I cannot use the using statement.

Instead I try to call the .Dispose() Method of the RSACryptoServiceProvider object at a suitable time but then I get the compile error message:

`System.Security.Cryptography.AsymmetricAlgorithm.Dispose(bool)' is inaccessible due to its protection level

Is RSACryptoServiceProvider not supposed to be used longer than one function call(using the using statement)?

How can I 开发者_如何转开发fix this, is not making the Dispose call an option?


The Clear method looks like it will call the dispose method:

This method is a simple call to the IDisposable.Dispose method. Calling Dispose allows the resources used by the AsymmetricAlgorithm class to be reallocated for other purposes. For more information about Dispose, see Cleaning Up Unmanaged Resources.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜