System.Security.Cryptography.X509Certificates.X509Certificate2Collection does not contain definition for 'Cast'

StackOverflow https://stackoverflow.com/questions/20616626

문제

I'm trying to create a MapReduce job using HDInsight .NET SDK tutorial.

In creating the JobSubmissionCertificateCredential object, specifically the following line:

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

I'm getting the following error: 'System.Security.Cryptography.X509Certificates.X509Certificate2Collection' does not contain a definition for 'Cast' and no extension method 'Cast' accepting a first argument of type 'System.Security.Cryptography.X509Certificates.X509Certificate2Collection' could be found (are you missing a using directive or an assembly reference?)

I have...

  • using System.Security.Cryptography.X509Certificates; at the top of my class.
  • ran Install-Package Microsoft.WindowsAzure.Management.HDInsight

Anyone know of any updates to this block of code that gets the Cast working? Thanks!

도움이 되었습니까?

해결책

Cast<T> is part of the Enumerable type located in the System.Linq namespace. Add a reference to that namespace and you'll be good.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top