add System.Security.Cryptography.Xml library to .net framework 4.6 project

5k Views Asked by At

I try to add package via nuget but this error occurs;

Could not install package 'System.Security.Cryptography.Xml 4.4.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Ok message is clear but there is a code peace and I moved it to my project. How can I make it work ? it requires this library

public string SignXml(XmlDocument xmlDoc, X509Certificate2 uidCert)
            {
                try
                {
                    // Create a SignedXml object.
                    SignedXml signedXml = new SignedXml(xmlDoc);
1

There are 1 best solutions below

0
On

SignedXml is already available in .NET Framework, you just need to add a reference to System.Security.dll

The NuGet package is for .NET Core, but can be used by .NET Standard (2.0) libraries which run on .NET Core 2.0+ or .NET Framework 4.6.1+. (The .NET Framework implementation just forwards to System.Security.dll).

Alternatively, upgrade your minimum target to 4.6.1 or higher (4.6.1 is 2 and a half years old at this point... and at 4.6 you’re 5 versions out of date).