Search code examples
visual-studio-code.net-corex509certificate2system.security

Visual Studio Code: Missing X509Certificate2UI


I get the following error when trying to use an X509Certificate2UI in VS Code:

The type or namespace name 'X509Certificate2UI' does not exist in the namespace 'System.Security.Cryptography.X509Certificates' (are you missing an assembly reference?) [netcoreapp1.1]

I've found a few sites that indicate the solution is to add the system.security.dll assembly, but these responses don't seem to be catered toward VS Code. I've already added the X509Certificates dependency to the project.json file, which doesn't seem to do me much good:

"dependencies": {},
"frameworks": {
  "netcoreapp1.1": {
    "dependencies": {
      "Microsoft.NETCore.App": {"type": "platform", "version": "1.1.0"},
      "System.Security.Cryptography.X509Certificates": "4.3.0" //"4.3.0-*"
     },
     "imports": "dnxcore50"
  }

Why am I getting this? What's wrong, and how can the issue be resolved?


Solution

  • X509Certificate2UI is not part of .NET Core. It's a Windows-only class, and a UI class at that, and it was not carried over.

    You will have to move to a UI-free solution, or cross-compile to target .NET Framework.