有没有人在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中,所以不知道;

最佳答案

您需要在项目中包括System.Security.dll的引用,因为它
不包含在mscorlib程序集中,但包含在System.Security
部件。

10-04 15:16