当前上下文中不存在名称"X509Certificate2UI" [英] name 'X509Certificate2UI' does not exist in the current context

查看:192
本文介绍了当前上下文中不存在名称"X509Certificate2UI"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET MVC4应用程序中使用X509Certificate2UI类是否有人遇到问题

Does anyone had problem using X509Certificate2UI class in an Asp Net MVC4 application

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

It complains that there is no 'X509Certificate2UI' name in the current context No idea since the class is in System.Security.Cryptography.X509Certificates;

推荐答案

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

You need to include reference for System.Security.dll into your project, since it is not included in the mscorlib assembly, but in the System.Security assembly.

这篇关于当前上下文中不存在名称"X509Certificate2UI"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆