抛出异常:' System.InvalidOperationException'在System.Core.dll中

时间:2015-05-29 20:54:04

标签: windows azure hadoop hadoop-streaming hdinsight

我正在尝试为HDInsight执行一项工作。 以下是获取证书代码,并在

中抛出异常
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);

我使用了以下命名空间: 使用系统; 使用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;

1 个答案:

答案 0 :(得分:0)

你得到的例外是什么?

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

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