2013-03-25 17 views
12

いAspのネットMVC4アプリケーションでX509Certificate2UIクラスを使って誰でも持っていた問題名「X509Certificate2UIは、」現在のコンテキスト内に存在しない

それは現在のコンテキスト には「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; 
    } 
} 

アイデアはクラスがSystem.Security.Cryptography.X509Certificatesにあるためです。

答えて

30

あなたはそれ がmscorlibアセンブリに含まれますが、System.Security アセンブリにされていないため、プロジェクトにSystem.Security.dllのための参照を含める必要があります。

+0

私の最初の答えを編集しました。質問をはっきりと読まなかった。 :( – freshbm

+0

これは早い段階で、テストしてうまくいくことがわかった。参考:http://www.pcreview.co.uk/forums/missing-x509certificate2ui-class-t2311992.html –

関連する問題