How do I manually Dispose RSACryptoServiceProvider?
- by phq
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?