名字& # 39;X509Certificate2UI& # 39;在当前上下文中不存在
本文关键字:上下文 不存在 X509Certificate2UI 名字 | 更新日期: 2023-09-27 18:05:36
是否有人在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
组装。