Create Your Application with the .NET SDK
Create Your Application with the .NET SDK
This section provides an outline of the basic workflow that you can follow to develop an application that uses the .NET SDK:
* 
For more information on the classes and methods used here, refer to the .NET SDK Reference.
You must add a reference to the ThingWorx-dotnet-common.dll. As of v.5.8.0, the appropriate version of the C SDK is installed with the .NET SDK to a location that the .NET SDK can find it. As long as you keep this structure, you no longer need to set environment variables or copy a C SDK dll. .
1. Create a class that extends the VirtualThing class. This class represents a Thing that has been created on the ThingWorx Platform with the RemoteThing Thing Template, and is the foundation that sets up the properties, services, and event subscriptions for the client application. These properties, services and events become accessible from the platform when the client application is bound to the corresponding Thing on the platform. You can create several VirtualThing classes and use several at a time.
2. Add properties, services, and event subscriptions to the extended VirtualThing class that you are creating by doing either of the following:
Use annotations. It is preferable to use annotations for well-known properties, services, and events that do not change.
Directly call methods in code. It is preferable to use methods for areas where annotations are not supported or for properties, services, and events that do change frequently.
3. Create an instance of the ClientConfigurator class. The ClientConfigurator class contains settings that the ConnectedThingClient uses to connect to the ThingWorx Platform, using the AlwaysOn protocol, and control its behavior.
4. At a minimum level, set the Uri and the properties of the SecurityClaims class. Optionally, set the Name and Reconnect Interval properties of the ClientConfigurator instance.
If the name property is not set, the .NET SDK will use a prefixed GUID for the gateway name in all BIND requests.
* 
When you supply it, this value is used for the gateway name in all BIND requests. If you are using a Gateway Name, make sure that it is unique to your specific agent instance. Your entire BIND request may be declined if another client has already claimed your Gateway Name.
5. Create an instance of the ConnectedThingClientClass, passing in the instance of the ClientConfigurator class you created. The ConnectedThingClient class contains methods that manage the connection to the platform.
6. Create an instance of the VirtualThing class you created.
7. Execute the bindThing method of the ConnectedThingClient class, passing in the VirtualThing instance. The bindThing method binds the properties, services, and events of the VirtualThing with the platform.
8. Execute the start method of the ConnectedThingClient class, which starts the message processing and connection monitoring tasks.
9. Add the custom functionality you want to implement for your machine/device.
* 
If your client is long-running, you may want to include a form of loop to handle processing, such as connect, perform an operation, and then disconnect. The processing logic you choose depends upon the specific requirements of your solution.
10. Execute the shutdown method of the ConnectedThingClient class, which stops the message processing and connection monitoring tasks.
Was this helpful?