本文介绍了当前上下文中不存在名称"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 contextNo 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 itis not included in the mscorlib assembly, but in the System.Securityassembly.

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

10-29 03:28