ObjectDisposedException when using extension method on RSAKeyValue
I was trying to write the following simple extension method for RSAKeyValue:
public static class RSAKeyValueExtensions
{
public static string ToXmlString(this RSAKeyValue keyValue)
{
return keyValue.GetXml().OuterXml;
}
}
However, it seems whenever I use ToXmlString
, I get an exception:
System.ObjectDisposedException: Safe handle has been closed
Is there a way to encapsulate the GetXml().OuterXml
so it isn't 开发者_JAVA技巧repeated in various places in my code without getting an ObjectDisposedException
?
I don't think the problem is that I was using an extension method, I think I was getting that exception because I was calling GetXml()
on the RSAKeyValue
instance after the underlying RSACryptoServiceProvider
had already been disposed.
精彩评论