I have started experimenting with C++/WinRT using Visual Studio 2017 Community Edition. I now have an environment in which I can build a debug version of a sample application and run it. I had to:
- download and install latest Windows 10 SDK
- update Visual Studio 2017 with the C++/WinRT package and templates
- update Windows 10 OS to the latest build, build 1803
Documentation and web pages described the C++/WinRT package update to Visual Studio and trying a compile of the example gave me an error indicating to download and install the latest Windows 10 SDK.
It was when I tried to actually run the debug build of the sample application that I found out I also needed Windows 10 Build 1803.
Is Windows 10 Build 1803 a requirement for running an application using Stadard C++ and C++/WinRT or was my experience due to using a Debug build?
Does this mean that people who have not upgraded their Windows 10 installation to at least Windows 10 Build 1803 will be unable to run an application developed with C++/WinRT?
Is it possible that an Enterprise or business customer will elect to eliminate the necessary C++/WinRT components when they do an Enterprise specific upgrade from their own servers with their own specific set of updates so that a C++/WinRT application will fail to run in their environment?
Is there some kind of packaging so that the necessary C++/WinRT components can be included with the application?
Addendum: Two test applications
I have retried from scratch the two test applications that I have worked with. This retry effort is after making the modifications of installing the latest Windows 10 SDK, 10.0.17134, and installing the C++/WinRT Visual Studio extension and updating my PC to Windows 10 1803.
The first C++/WinRT application that I tried was a console application from an article by Kenny Kerr, C++ - Introducing C++/WinRT which had the following sample application:
#pragma comment(lib, "windowsapp")
#include "winrt/Windows.Foundation.h"
#include "winrt/Windows.Web.Syndication.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Web::Syndication;
int main()
{
initialize(); // NOTE: Generates compiler error C3861: 'initialize': identifier not found
Uri uri(L"http://kennykerr.ca/feed");
SyndicationClient client;
SyndicationFeed feed = client.RetrieveFeedAsync(uri).get();
for (SyndicationItem item : feed.Items())
{
hstring title = item.Title().Text();
printf("%ls\n", title.c_str());
}
}
I finally teased out a procedure for creating, compiling, and running this test source was as follows. Starting with opening Visual Studio 2017 Community Edition, I did the following:
- File -> New -> Project and use Windows Desktop, Windows Console application template
- keeping the
#include "stdafx.h"
but replace the template generatedmain()
with the above source - right click on solution in Solution Explorer, select Properties, open C/C++ -> Language and change "C++ language standard" to "ISO C++17 Standard (/std:c++17)"
The "Windows SDK Version" in "Configuration Properties" -> "General" was set to 10.0.17134.0.
The build failed with a compilation error of error C3861: 'initialize': identifier not found
. Further searches found this article, cppwinrt.exe in the Windows SDK, which contained a sample application that used init_apartment();
instead of initialize();
so with that change my sample application compiles and runs producing a list of articles as output.
This Microsoft docs article, Get started with C++/WinRT, dated 05/07/2018 has a console example that uses init_apartment();
rather than initialize()
. That example is also a Syndication Feed but to a different URL.
The second test application used the C++/WinRT template of "Windows Universal" -> "Blank App (C++/WinRT)" which generated a sample application which compiled and ran. In the "Properties" -> "General" dialog the "Target Platform Version" was set to 10.0.17134.0 and the "Target Platform Minimum" was set to 10.0.15063.0.