代码之家  ›  专栏  ›  技术社区  ›  Sarah Vessels

序列化可序列化类中的RSAKeyValue属性

  •  0
  • Sarah Vessels  · 技术社区  · 14 年前

    [Serializable] RSAKeyValue :

    [XmlElement(PUBLIC_KEY_TAG_NAME)]
    public RSAKeyValue Key { get; private set; }
    

    System.InvalidOperationException:无法序列化System.Security.Cryptography.KeySizes,因为它没有无参数构造函数。

    当我打电话时就会发生这种情况 XmlSerializer.Serialize . 我肯定是因为 RSAKeyValue公司 属性,因为所有其他序列化的属性都是简单字符串。我能怎么办?我应该围绕一个 RSAKeyValue公司 正确序列化/反序列化的实例?

    下面是一些可以反序列化为 RSAKeyValue公司 实例:

    <RSAKeyValue>
      <Modulus>long string here...</Modulus>
      <Exponent>short string here</Exponent>
    </RSAKeyValue>
    
    1 回复  |  直到 14 年前
        1
  •  1
  •   John Saunders    14 年前

    首先,XML序列化程序忽略 [Serializable] 属性。

    你想完成什么?也许您可以使用数据协定序列化程序完成相同的任务?