19

有人在 Asp Net MVC4 应用程序中使用 X509Certificate2UI 类有问题吗

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;
    }
}

它抱怨当前上下文中没有“X509Certificate2UI”名称不知道,因为该类在 System.Security.Cryptography.X509Certificates 中;

4

1 回答 1

46

您需要在System.Security.dll项目中包含参考,因为它不包含在mscorlib程序集中,而是包含在程序集中System.Security

于 2013-03-25T14:39:10.443 回答