.NET Standard 2.0 and System.Security.Crytography.Cng

  • Thread starter Thread starter GreenStone90
  • Start date Start date
G

GreenStone90

Guest
Hi,

I am trying to create a .NET Standard 2.0 library that can be called by a .NET 4.7.2 application.

I am getting an error: System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Security.Cryptography.Cng, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'


Here are the steps (in my little test setup);

1.) Create a .NET Standard 2.0 library in Visual Studio 2017

2.) Get a NuGet package for System.Security.Crytography.Cng (it gives me version 4.5.0 as the latest version)

3.) In the library dll, make a call to System.Security.Crytography.Cng (all compiles ok)

4.) Create a simple command line program in .NET 4.7.2 and reference this .NET Standard 2.0 library. (all compiles ok).

5.) Run the command line application. When the library is called, gives the error: System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Security.Cryptography.Cng, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'


Thoughts on the issue?


-------------------

Code Sample:

COMMAND LINE APP (.NET FRAMEWORK 4.7.2)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
int x = ClassLibrary1.Class1.GetEncryptedValue();
}
}
}


==========================

CLASS LIBRARY (.NET STANDARD 2.0)

using System;

namespace ClassLibrary1
{
static public class Class1
{
static public int GetEncryptedValue()
{
int i = 3;

System.Security.Cryptography.AesCng aes = new System.Security.Cryptography.AesCng();

return i;
}

}
}









greenstone90

Continue reading...
 
Back
Top