OpenChannel Method
Collapse the table of content
Expand the table of content

SecureElementSession.OpenChannel Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Opens a logical channel with the Secure Element, using a specific applet on the Secure Element.

Namespace:  Microsoft.Phone.SecureElement
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)

public SecureElementChannel OpenChannel(
	byte[] appletId
)

Parameters

appletId
Type: System.Byte []
The applet ID of the targeted applet. Must be between 5 and 16 bytes.

Return Value

Type: Microsoft.Phone.SecureElement.SecureElementChannel
An instance of SecureElementChannel on success; otherwise, null.

ExceptionCondition
ArgumentException

The appletId size is invalid. It must be between 5 and 16 bytes.

IOException

Could not communicate with the Secure Element. This exception can also occur if there are currently no available channels to open. You should consider implementing retry logic in your code to try again after a period of time.

COMException

Could not communicate with the Secure Element. This exception can also occur if there are currently no available channels to open. You should consider implementing retry logic in your code to try again after a period of time.

InvalidOperationException

The Secure Element is closed and cannot be used.

UnauthorizedAccessException

The calling application does not have permission to access the given applet.

FileNotFoundException

No applet with the given applet ID exists on the Secure Element.

Channels are a shared resource and attempts to open a channel may fail if none are available. Therefore, it is best practice to close the channel, by calling the SecureElementChannel.Dispose method, as soon as you are finished with it. You should also consider implementing a retry mechanism to handle the case when a call to OpenChannel fails.

The SelectResponse property should be checked when this method completes. This value is the byte array representing the APDU response from the Secure Element. The last two bytes are sw1 and sw2, the status code bytes.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft