2

I have class library project in .net standard 2.0.3 where I'm using System.Security.Cryptography.Xml to sign a xml document with a privateRSAkey.

var sign = GetXmlSign(doc, rsa);

private static XmlElement GetXmlSign(XmlDocument xml, AsymmetricAlgorithm key)
{
    var signedXml = new SignedXml(xml) {SigningKey = key};
    var refer = new Reference {Uri = ""};
    reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
    signedXml.AddReference(refer);
    signedXml.ComputeSignature();
    return signedXml.GetXml();
}

Now when I'm calling GetXmlSign(doc, rsa); I'm getting the exception below.

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Security.Cryptography.Xml, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'

NuGets

Nuget Packages

Note: There is no Nuget "System.Security.Cryptography.Xml" with Version=4.0.1.0

Sabir Hossain
  • 1,183
  • 1
  • 25
  • 46

1 Answers1

4

The problem was really simple and stupid..! I just had to add the same System.Security.Cryptography.Xml Nuget in my main project where from I calling the library.

Sabir Hossain
  • 1,183
  • 1
  • 25
  • 46