Sabir Hossain
Sabir Hossain

Reputation: 1205

Could not load file or assembly 'System.Security.Cryptography.Xml

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

Upvotes: 2

Views: 5002

Answers (2)

Klauder Dias
Klauder Dias

Reputation: 7

For me works only after change the settings in Application Group on the IIS. In my case, the value was "false" and I change to "true". You have access to this page on the Advanced Settings.advanced settings

enter image description here

Upvotes: -1

Sabir Hossain
Sabir Hossain

Reputation: 1205

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.

Upvotes: 4

Related Questions