I am converting an existing multi-target Silverlight/.NET project to a Portable Class Library project in order to reduce the number of projects that are required to support multiple Microsoft platforms.
I have an error in one class that is using the System.Security.Cryptography namespace
The type or namespace name 'Cryptography' does not exist in the namespace 'System.Security' (are you missing an assembly reference?)
This namespace is available in Silverlight and I am wondering why the Portable Class Library does not support it?
One reason could be that this behaviour is by design: any cryptography related code should not be present in a client side API.
No unfortunately, Portable Library does not support Crypto. However, we've added support for it in PclContrib.
I would suspect it does not support it. Members on classes in that Namespace are marked with an image:
You can find which members are supported by the Portable Class Library project in the reference topics for the .NET Framework Class Library. In the members table for a class, the following Portable Class Library icon appears next to supported members.
That image is lacking in every class I examined in the documentation.
This namespace is available in Silverlight and I am wondering why the Portable Class Library does not support it?
I can't say for sure; but it does appear to be lacking under XNA for the XBox 360 platform. Even then, I believe your conclusion is correct - it isn't an API that is very popular on a front end. Then underlying code is also extremely non-portable. A large portion of the Crypto namespace is accomplished by P/Invoking down to the operating system. I suspect they could make it portable as they did with Silverlight; but that may just not have been on their radar just yet.
I suggest you use PclCrypto. It's the simplest to use and invokes platform crypto rather than trying to implement it itself, which means less security risk and faster performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With