Building C++ WinRT Apps on Windows 10 LTSB

Microsoft released a version of Windows 10 called the LTSB, which stands for the Long Term Service Branch edition. You’ll see this edition on medical devices, construction devices and even media devices, such as the Seneca media set top box. You can kind of look at this edition as a full blown IoT edition of Windows 10.

This edition of Windows 10 follows a pattern of stability long term updates, meaning it takes a long time for you to see a major update. You can still get security updates, but updates like Anniversary edition, Creator’s edition and Windows Insider editions are not available. The purpose for this edition is to offer a stable long term version that can last for 5-10 years as is without breaking any existing applications.

This is great for low power always on type devices such as medical devices that need to be on life support type scenarios. Another example is a media box, where the life span of a TV or video player could easily be 2-3 years. No major update need to be applied for an application that won’t change over that time frame.

This edition of Windows is a severely scaled down version. There’s no Cortana, no Office, no Windows UWP Store, no modern apps such as the Camera app, or even Edge browser.

So, you’re probably wondering if there are no modern apps and very little applications to function with, can you develop for it?

Recently I’ve been tasked with build a custom application that will run on it with some custom software and USB hardware. I was pleasantly surprised to know that you can run .Net apps, meaning WPF, WCF, Windows Forms, Web Apps, and etc on it. Obviously you can run other frameworks as well such as Node.js, and python. You can run databases on it as well. And yes, even though there is no modern UWP apps, you CAN run UWP applications, after all it is still windows 10.

Though there is no store to install UWP apps you’ll need to side load your apps to install them.

C++ applications are also supported, and for my purposes I went down the path of building a cppwinrt application. At first everything went smooth locally on my laptop. My custom application ran and accessed the usb devices, I retrieved the custom data sets, performed my AI logic and my client was impressed.

Afterwards I decided to take my application for a test run on the LTSB device. My application consists of a test harness built using WPF, and the actual application/service built with C++/WinRT. The first thing I noticed was .Net was not installed. So I went ahead and installed .Net 4.7.1, no problem. The next thing I ran into was that the VC Runtime was not installed. So no biggy, I installed the VS.Net 2017 VC Runtime. At this point it was time to deploy my custom application. I deployed my WPF Test harness, and everything worked fine. I then deployed my C++/WinRT application in Debug mode and all things came to a halt.

My deployment for the C++/WinRT (Debug build) contained all the necessary debug versions of the libraries, however no matter what I did, the application kept yielding Invalid format. Kind of like if you’re trying to run a x64 bit application built on x64 bit libraries but using x86 DLLs. I couldn’t figure it out. My .Net applications were built the same way and it ran fine, yet my C++/WinRT application wouldn’t run.

So I decided to take it slow, and try to get a simple Win32 console application to run. Lo and behold I ran into the exact same problem. I then took another existing simple Win32 application I found in one of my repos, and amazingly it ran just fine. I then proceeded to copy the code as in into my environment compile it and see if it ran. It didn’t. I was confused. Why would an already built application run just fine, but when I re-compile it with what I thought was the same build options didn’t and that’s when I saw the issue.

It appears as though LTSB version of Windows 10 requires your C++/WinRT application to be compiled as Release The debug symbols and versions of OS DLL’s don’t appear to be present (as I wouldn’t expect them to) but the debug DLL’s we typically use are apparently linked to another build of the OS version system libraries. When you package these debug DLL’s with your application, they don’t properly link to the LTSB OS libraries, and thus you get an invalid format runtime error.

So as a quick note to self, when building and testing apps on the LTSB version of Windows 10, compile your test code to Release configuration, and use Trace Statements to figure out what’s going on. SysInternal tools were the key to figuring this stuff out, so cool thing is those tools work on LTSB as well.

Happy Koding!!!