Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Creates a connection to the device agent to exchange data.
Namespace: Microsoft.SmartDevice.Connectivity
Assembly: Microsoft.SmartDevice.Connectivity (in Microsoft.SmartDevice.Connectivity.dll)
Syntax
'Declaration
Public Function CreatePacketStream ( _
serviceId As ObjectId _
) As DevicePacketStream
'Usage
Dim instance As RemoteAgent
Dim serviceId As ObjectId
Dim returnValue As DevicePacketStream
returnValue = instance.CreatePacketStream(serviceId)
public DevicePacketStream CreatePacketStream(
ObjectId serviceId
)
public:
DevicePacketStream^ CreatePacketStream(
ObjectId^ serviceId
)
public function CreatePacketStream(
serviceId : ObjectId
) : DevicePacketStream
Parameters
serviceId
Type: Microsoft.SmartDevice.Connectivity.ObjectIdA unique service ID.
Return Value
Type: Microsoft.SmartDevice.Connectivity.DevicePacketStream
A DevicePacketStream object that can transfer data between the device agent and the development computer.
Exceptions
| Exception | Condition |
|---|---|
| SmartDeviceException | Occurs if a COM exception is thrown by underlying COM components. |
| DeviceNotConnectedException | Occurs if a device is not connected. |
Remarks
There must be a device-side agent ready to accept a connection on the same service ID. The device-side agent is deployed when Start is called. A device agent can accept multiple stream connections on different service IDs.
Examples
' Open communication channel with device agent.
Dim ps As DevicePacketStream = ra.CreatePacketStream( _
New ObjectId("2FAD740C-B5D3-4ad0-BE23-5682503584BF"))
' Create and write a packet of data.
Dim packet As Packet
packet = New Packet()
Dim i As Integer
For i = 0 To 3
packet.WriteInt32(i)
Next i
packet.WriteString("Hello Smart Device")
ps.Write(packet)
// Open communication channel with device agent.
DevicePacketStream ps = ra.CreatePacketStream(
new ObjectId("2FAD740C-B5D3-4ad0-BE23-5682503584BF"));
// Create and write a packet of data.
Packet packet;
packet = new Packet();
for (int i = 0; i < 4; i +) packet.WriteInt32(i);
packet.WriteString("Hello Smart Device");
ps.Write(packet);
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.