Export (0) Print
Expand All

CngKey.GetProperty Method

Gets a property, given a name and a set of property options.

Namespace:  System.Security.Cryptography
Assembly:  System.Core (in System.Core.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)]
public CngProperty GetProperty(
	string name,
	CngPropertyOptions options
)

Parameters

name
Type: System.String

The name of the desired property.

options
Type: System.Security.Cryptography.CngPropertyOptions

A bitwise combination of the enumeration values that specify options for the named property.

Return Value

Type: System.Security.Cryptography.CngProperty
An object that contains the raw value of the specified property.

ExceptionCondition
ArgumentNullException

name is null.

CryptographicException

All other errors.

The purpose of this method is to return the value of an arbitrary property of the key. The typical way to retrieve properties is by using the property accessors provided by the CngKey class. CngKey provides wrappers for several, but not all, properties. The GetProperty method is primarily used to access the value of a property that is not wrapped.

This method is useful in the following cases:

  • A new version of the operating system supports a new Cryptography Next Generation (CNG) key property that does not have a wrapper.

  • You add a custom property to the key.

The options parameter is specifically used to indicate the following:

  • Whether the property is built-in, or custom.

  • Whether the property should be persisted with the key.

These options must match the value that the property was set with, or the property will not be found.

CryptographicException is thrown if the property cannot be found. You should call the HasProperty method first to avoid the exception instead of wrapping the method call in a try/catch block.

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5

Community Additions

ADD
Show:
© 2015 Microsoft