Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

name 'X509Certificate2UI' does not exist in the current context

Does anyone had problem using X509Certificate2UI class in an Asp Net MVC4 application

using System.Security.Cryptography.X509Certificates;


private static X509Certificate2 PickCertificate(StoreLocation location, StoreName name)
{

    try
    {
        store.Open(OpenFlags.ReadOnly);
        //PROBLEM IS HERE
        X509Certificate2 cert = X509Certificate2UI.SelectFromCollection(store.Certificates, "Caption", "Message", X509SelectionFlag.SingleSelection)[0]; 
}
    catch (Exception)
    {               
        throw;
    }
}

It complains that there is no 'X509Certificate2UI' name in the current context No idea since the class is in System.Security.Cryptography.X509Certificates;

like image 859
Guilherme Longo Avatar asked Mar 25 '13 14:03

Guilherme Longo


1 Answers

You need to include reference for System.Security.dll into your project, since it is not included in the mscorlib assembly, but in the System.Security assembly.

like image 153
freshbm Avatar answered Sep 23 '22 02:09

freshbm