2013-03-25 56 views
12

是否使用X509Certificate2UI類在ASP淨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;

回答

30

您需要包含到你的項目爲System.Security.dll參考,因爲它 沒有在mscorlib組件包括在內,但在System.Security 組裝。

+0

現在試試,我編輯了我的第一個答案,沒有清楚地讀出問題。 :( – freshbm 2013-03-25 14:59:08

+0

這樣會更好,發現早些時候,現在我可以測試它並正常工作了。參考:http://www.pcreview.co.uk/forums/missing-x509certificate2ui-class-t2311992.html – 2013-03-25 16:36:50

相關問題