Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlatformNotSupportedException when executing a general LINQ query

I get a weird exception on a XP machine when I run a LINQ query.

{"The specified cryptographic algorithm is not supported on this platform."}

at System.Security.Cryptography.CapiNative.AcquireCsp(String keyContainer, String providerName, ProviderType providerType, CryptAcquireContextFlags flags, Boolean throwPlatformException)

There is no inner exception and the stacktrace is above.

I would expect that kind of exception when cryptography providers are in play etc., but with LINQ, I have no idea. I have to admit I am new to LINQ.

Here's the slightly simplified LINQ Query in EF 4.1:

using (var c = new MyContext())
{
    var v = (from item in c.Items where (item.ID==someid) select item).FirstOrDefault();
    return v;
}

Any insight?

EDIT: As already noted in the comments section below, I am using .NET 4.0 with EF 4.1, the connection string is a plain ol' app.config string with no crpto settings or other connection string options applied.

like image 543
John Avatar asked Sep 02 '11 10:09

John


1 Answers

I strongly suspect it's the security being used trying to talk to the database - check your connection string and any options you have with respect to encrypting the connection string itself.

like image 156
Jon Skeet Avatar answered Oct 15 '22 12:10

Jon Skeet