开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜