简体   繁体   中英

load certificate in WP7

in WP7 I Tried to load certificate to get a public key from it and I use this

X509Certificate x509 = null;
x509 = X509Certificate.CreateFromCertFile(CertificateFilePath);

and I got this exception:

{System.MethodAccessException: Attempt to access the method failed: System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(System.String)

any one have an idea about this problem ? there anther way to read cert file in WP7 ?

This is an inherent limitation put in place because your application is running in a sandboxed environment, and therefore is not exactly an app that would be classified as "trusted" by Silverlight standards. To quote MSDN :

This member can be used only by trusted applications. If you try to use this member in a partial-trust application, your code will throw a MethodAccessException exception. This member is security-critical, which restricts its use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM