【问题标题】:name 'X509Certificate2UI' does not exist in the current context当前上下文中不存在名称“X509Certificate2UI”
【发布时间】:2013-03-25 14:27:08
【问题描述】:

有人在 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 中;

【问题讨论】:

    标签: c# asp.net-mvc asp.net-mvc-4


    【解决方案1】:

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

    【讨论】:

    • 现在试试,我编辑了我的第一个答案,没有看清楚问题。 :(
    • 这样更好。发现之前,刚才我可以测试它并且工作正常。参考:pcreview.co.uk/forums/…
    猜你喜欢
    • 2013-10-02
    • 2014-04-22
    • 2017-06-17
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 2020-11-02
    相关资源
    最近更新 更多