We are to the last post of this tutorial that guides us through the creation of a proprietary component (using the M2Mqtt library as an example) for Platform Builder and its inclusion in the Windows Embedded Compact 2013. In this final post we will see how you can use this component in a sample managed application using also debugging.

SDK and Application Builder

When we build Windows Embedded Compact 2013 image that we have to provide to the software development team that will implement the high-level application for the target device, we must necessarily also make available its SDK. It contains all the header files and static libraries that developers can use to build applications in native code, avoiding the use of the APIs that we have not included in our image. Typically we would not need the SDK with managed applications based on .Net Compact Framework but unfortunately without any SDK installed, Visual Studio 2012 does not make available any templates for applications based on Windows Embedded Compact 2013. This SDK can be created and generated by the Platform Builder clicking on SDKs and then clicking on the "Add New SDK", the build system will produce a MSI file to distribute to developers need it.


In addition to the SDK, the development team needs to install the Application Builder for Windows Embedded Compact 2013, which you can download here.

For debugging support through Application Builder, you must include into the image the corresponding component "Application Builder Debugging Support" from catalog items that can be found in Core OS -> Windows Embedded Compact -> Applications and Services Development -> Diagnostics and Debugging tools.


Using these two tools, developers have the task of developing applications for the target device and not the operating system has no need to install Platform Builder.

Developing, deploy and debugging of a simple managed application

After installing the SDK (generated from the image built) and Application Builder on the development PC, we can start Visual Studio 2012 and select the template Visual C # -> Windows Embedded Compact 2013 -> <generated SDK> (in my case it is VirtualCEPC2013); for our example is fine a Console Application.


Let's add a reference to the M2Mqtt assembly (must be the same distributed with the component M2Mqtt4CE due to Public Key Token) but we have to set the “Copy Local” property to False, so that it will not be deployed with the application being already included in the OS image.


We are ready to write our application that will periodically publish a message with random data on a topic through the use of Mosquitto broker to install on a PC.

   1: Console.WriteLine("Welcome to C# on Windows Embedded Systems");
   3: MqttClient client = new MqttClient(IPAddress.Parse(""));
   4: client.Connect("netcfclient");
   6: Random random = new Random();
   7: while (true)
   8: {
   9:     int data = random.Next(10);
  10:     client.Publish("/data", Encoding.ASCII.GetBytes(data.ToString()));
  11:     Thread.Sleep(1000);
  12: }

Start the target device (in my case the Virtual PC) and get the IP address assigned to set it in the project properties of our application for Core Connectivity connection.


Set a breakpoint at the first instruction and start the application, immediately after the deploy we will see the debugger work properly and allow us to run the application step by step directly on the target !