It’s been a while since my last post and now I think I have something to share, related to LOB Metro Apps and Serial Port Communication. Winodws 8.1 provides a really good platform for companies to build nice, touch friendly user experience. For some companies, especially for industrial, it is important for platform to support different type of devices. Even now it is a bit difficult to find a PC which still has Serial Port, many third party devices still use a Serial Port as a main point of communication. Windows 8.1 added back support for Serial Port communication, but you need to have a proper Serial to USB converter which is compatible with USB CDC standard protocol, what is really hard to find in real life. If you are lucky and you have found a way how to get that converter, this post is not for you and you better look at the Microsoft sample here However for all other developers, who are looking for kind of easy way to include integration of Serial Port  in their Windows 8 app, this post will be useful.

As I mentioned in my previous posts, I have been working on some very interesting project, related to Kiosk software built for Windows 8. One of the coolest feature, in my opinion, was a RFID reader integration. Most of the RFID readers support only Serial Port communication and I have tried couple different ways how to connect that sort of devices to my Metro app. You can easily find a Serial to Bluetooth converter on the market and Windows 8 device api does it job really well, when you want to have a connection to Bluetooth device. However, device api will always prompt for access from user, what wasn’t good in my case.

In Windows 8.1 Update 1, the Microsoft introduced a new component called – Broked Windows Runtime Component (the white paper could be found here – here) The idea behind, in simple words that Broked component allows inter process communication between win32 app and your metro app, using a kind of proxy. So, in this post I will go through a simple scenario, when we handle a Serial Port communication inside Broked Component and pass data to your metro app. The good thing also about broked component is that if you app is in the sleep mode, it still can receive a data and you can activate your app based on what you received from  Broked component. So let’s start.


Setting up the solution

To be able to create a new project in VS 2013, you need to get the last update for VS. Create a new Windows Store blank app called “SerialPortSampleApp”:

20-10-2014 10-12-11 AM

Now, right click on solution and add new Project, called it “SerialPortSampleAppBroked”

20-10-2014 10-15-03 AM

Rename the class to SP, so your solution will look like this:

20-10-2014 10-18-24 AM


New, add a new item project to solution. It is going to be our proxy project.

20-10-2014 10-19-50 AM

Once all done, come to Proxy project and add reference to SerialPortSampleAppBroked project:

20-10-2014 10-21-53 AM


After, come to SerialPortSampleApp and add reference to your Proxy Project

20-10-2014 10-23-27 AM


Build the solution. The last step before we start modifying  the code is to change Proxy project properties to allow VS to register new dll on build. Right click on Proxy project, go to properties and change “Register Output” to YES.

20-10-2014 10-26-18 AM

Close VS and run it again with Administrator rights. Now we are ready to start.


Main Part

So far we have created 3 projects – one is to keep our Serial Port logic, second one is our Metro App, which will provide a UI, and the last one is a Proxy project which will play a role of Bridge between two projects. As you can see, we change the properties of Proxy project to register a new dll when we build a solution. The metro app has a reference to Proxy project and it will expect a dll to be registered in the system. The last part is we need to change the Metro App manifest file, to let the app know where to find an implementation of our SerialPort library.

So come to your App and right click on manifest file and select – view code:

20-10-2014 10-35-44 AM

In my case the path to Broked Project dll is “C:\Users\nicksav\Documents\visual studio 2013\Projects\SerialPortSampleApp\SerialPortSampleAppBroked\bin\Debug”

Save manifest and build the solution again. Now are ready to ad Serial Port logic into Broked component.

Right click on your Broked project and select “Unload Project”

20-10-2014 10-40-21 AM

Next, edit csproj file. We are going to add reference to System.IO library.

20-10-2014 10-42-20 AM

Add System.IO reference:

20-10-2014 10-43-46 AM

Save the file and reload the project.

Now come to SP.cs file and add following code:

This is just a standard code to use when communicating to Serial Port. You change the settings, based on your Device.  The most impotent part here is “PeriodicEvent”. This event is triggered when the data comes from Serial Port. Build the solution and open “MainPage.xaml.cs”

20-10-2014 10-57-43 AM


Add the following code:

That’s all. Now you are able to get data from Serial Port. Keep in mind that Microsoft Store wont allow such apps, it is only for side loading.

The source could be found here:






Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">