2015-05-29 46 views
0

我正在尝试执行HDInsight的作业。 以下是获取证书代码,其在抛出的异常:System.Core.dll中的'System.InvalidOperationException'

X509Certificate2 cert= store.Certificates.Cast<X509Certificate2>().First(item => item.FriendlyName == certFriendlyName);" 

// Get the certificate object from certificate store using the friendly name to identify it 

X509Store store = new X509Store(); 
store.Open(OpenFlags.ReadOnly); 
X509Certificate2 cert= store.Certificates.Cast<X509Certificate2(). 
First(item => item.FriendlyName == certFriendlyName); 
JobSubmissionCertificateCredential creds =new JobSubmissionCertificateCredential (new Guid(subscriptionID), cert, clusterName); 

抛出一个异常,我用下面的命名空间: 使用系统; using System.Collections.Generic;

using System.Text; 
using System.Threading.Tasks; 
using System.IO; 
using System.Threading; 
using System.Security.Cryptography.X509Certificates; 
using Microsoft.WindowsAzure.Management.HDInsight; 
using Microsoft.Hadoop.Client; 
using System.Linq; 
+0

它继续抛出一个异常,我找不到任何解决方案上的MSDN,除了一些类似的职位,其中解决方案是使用System.Linq,我已经在这里使用。 –

回答

0

你有什么特例?

此代码使用当前的用户存储,是您当前用户存储中的证书吗?

我建议您先列出所有证书友好名称以验证它是否存在。

相关问题