在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;
答案 0 :(得分:34)
您需要在项目中包含System.Security.dll
的引用,因为它
未包含在mscorlib
程序集中,但在System.Security
中
组装