相关疑难解决方法(0)

使用SignedXml类添加基于Id属性的引用时,"格式错误的引用元素"

当存在名称空间前缀时,无法通过Id属性对元素进行签名:

void Main()
{
    var doc = new XmlDocument();
    doc.LoadXml("<root xmlns:u=\"myuri\"><test u:Id=\"_0\">Zebra</test></root>");

    SignedXml signedXml = new SignedXml(doc);
    signedXml.SigningKey = new RSACryptoServiceProvider();

    Reference reference = new Reference("#_0");
    signedXml.AddReference(reference);

    signedXml.ComputeSignature();
}
Run Code Online (Sandbox Code Playgroud)

ComputeSignature() 这里会出现'格式错误的参考元素'应该怎么做?

c# xml soap cryptography xml-signature

19
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

cryptography ×1

soap ×1

xml ×1

xml-signature ×1