.NET / C # certificate read from store throws AccessViolationException

I have a very strange code exception that should work but not work.

I have the following code:

X509Certificate certificate;
X509CertificateStore store = X509CertificateStore.LocalMachineStore(X509CertificateStore.MyStore);
store.OpenRead();
var certs = new X509CertificateCollection();
Microsoft.Web.Services2.Security.X509.X509CertificateCollection findCertificateBySubjectName = store.FindCertificateBySubjectName("localhost");

foreach (X509Certificate tempCertificate in store.Certificates)
{
    if (String.CompareOrdinal(tempCertificate.Subject, "") == 0)
    {
        certs.Add(tempCertificate);
    }
}

      

enter image description here The current code runs inside the w3wp process under administrator privileges. But I am getting the exception you can see in the screenshot. I tried a lot of things, give access to all certificates, change users, reimport certificate. I would appreciate any help or assistance.

+3
c # .net certificate access-violation x509certificate


source to share


No one has answered this question yet

Check out similar questions:

1658
Get int value from enum in c #
1270
Why not inherit from List <T>?
838
How do I turn a C # object into a JSON string in .NET?
744
Reading settings from app.config or web.config in .net
537
How do I get the current username in .NET using C #?
530
How do you make a deep copy of an object in .NET (like C #)?
1
Power certificate to be stored as machine certificate
1
NETWORK SERVICE user cannot read certificate windows server 2012
0
X509Chain.Build () to revoke a revoked certificate. FROM#
0
C # - Accessing HTTPS url from .NET application (without importing server certificates) does not throw SSL exception



All Articles
Loading...
X
Show
Funny
Dev
Pics