2

I would like to make an app for my Lumia stuck on Win 10.0.14393 (or 1609) using C++/WinRT. I've created a Blank app project with

  • Target platform version: 10.0.17134.0 and
  • Target platform min. version: 10.0.14393.

The project fails to compile with the following errors:

error C2039: 'DisconnectUnloadedObject': is not a member of 'winrt::BlankApp2::implementation::MainPageT'

error C2039: 'UnloadObject': is not a member of 'winrt::BlankApp2::implementation::MainPageT'

Is this a bug or intentional behavior? Please note, that setting any newer min. version results in successful build.

neonxc
  • 802
  • 9
  • 21
  • 2
    It's not C++/WinRT that's your problem. The problem is that you're using `x:Load` in your XAML, but [`x:Load` requires 15063](https://learn.microsoft.com/en-us/windows/uwp/xaml-platform/x-load-attribute). – Raymond Chen Oct 28 '18 at 03:40
  • @Raymond, You are most probably pointing in the right direction. Can you also tell me how to avoid it? I can't see it in neither XAML file. – neonxc Oct 28 '18 at 12:15
  • Find out where the DisconnectUnloadedObject is coming from. If it came from generated code, then find out which XAML markup caused that code to be generated. – Raymond Chen Oct 28 '18 at 14:27
  • I'm sorry, but I can't find, which XAML markup generates this function definition. I removed almost everything from the (fresh new) MainPage.xaml and the problem remains. I tend to believe this is a problem in configuration of a tool, that transforms idl files to implementation ones. Unfortunately I haven't found a way to tune this proces without giving up XAML files. – neonxc Oct 28 '18 at 19:08
  • I would suggest using an older compiler, Visual Studio 2015. I have moved C++/WinRT source between 2015 and 2017 and there seem to be some real differences. I seem to always have a problem and end up fiddling with the solution properties. This whole area of a moving target with C++/WinRT seems a bit fraught and chaotic. – Richard Chambers Nov 06 '18 at 04:14
  • @Richard, there is still bounty applicable for about 20 hours, if you are interested, you can post your proposal as an answer and get it. It's going to vanish otherwise. – neonxc Nov 06 '18 at 07:50

2 Answers2

1

The latest version of C++/WinRT can support all versions of Windows 10, including 14393 and older versions as well.

Keep in mind that C++/WinRT is both a library and a language projection. The language projection provides access to Windows APIs targeting a given version of Windows. Each version introduces new APIs. So if you want to target a minimum version of Windows, you need to ensure that you limit yourself to the APIs available on that version of Windows. I would however recommend using the latest compiler and the latest Windows SDK as they include many bug fixes.

Kenny Kerr
  • 3,015
  • 15
  • 18
  • thank you for your response. I'm afraid you didn't get my point though. I understand that I need to stay within the range of Min. SDK functionality. The problem is I can't find a way how - even in a freshly created project. (downvote not mine) – neonxc Nov 08 '18 at 07:54
  • How? By setting "Target Platform Version" to the latest version of the SDK that you have installed (RS5 or later). – Kenny Kerr Nov 09 '18 at 22:07
  • 1
    The trick is that this version affects which version of the toolchain is used to build the project. An older version not only restricts which subset of the API is available, but also forces the project to be built with older tools that do not include all of the fixes in subsequent versions. – Kenny Kerr Nov 09 '18 at 22:22
  • Using newer SDK (17763) as _Target Platform Version_ actually did the trick and the code compiles & works. Thank you @Kenny. – neonxc Nov 13 '18 at 13:27
0

I suggest you use Visual Studio 2015 when targeting older C++/WinRT and Windows 10 updates. My impression is that most of those were delivered on top of Visual Studio 2015 with Visual Studio 2015 updates and Windows 10 SDK updates and C++/WinRT updates.

When using Visual Studio 2015 with C++/WinRT, you will need the latest update, Update 3. Check for updates and make sure that your copy of Visual Studio 2015 has the most recent updates. I was just using an install of Visual Studio 2015 Enterprise to recompile something that compiles fine with Visual Studio 2017 and found that I was missing tools and SDKs including for Win 10 SDK 10.0.14393 that were in the Update 3 which I had not yet installed.

You can also go to Programs and Feature from within Control Panel, look for Microsoft Visual Studio 2015 in the list and then do a right mouse click and Change which will allow you to check what is installed and change anything.

Working with C++/WinRT over the last few months I have used both the Visual Studio 2017 Community Edition and the Visual Studio 2015 Enterprise Edition.

I have seen differences when moving a solution from VS 2015 to VS 2017 that required me to review the Properties page of the solution. See also the discussion in synchronizing SDK with Windows 10 update and using WinRT with Standard C++

Working with the latest Windows 10 updates and VS 2017 works best for me because I am able to target the recent Windows 10 updates. However I have found that trying to target older Windows 10 updates with VS 2017 can be problematic.

I'm sorry that I can not be more specific. This whole area of C++/WinRT and Windows 10 updates has much more cowboy than I would like though it now seems to be settling down.

C++/WinRT is a template library that was originally an open source project on GitHub. My impression is that Microsoft has acquired it and it is now a standard product offering. I believe there was a significant rewrite of C++/WinRT at one time as the Visual Studio 2015 and then Visual Studio 2017 moved to implement more of the C++17 and proposed C++20 standards and the Technical Specifications for coroutines.

This seems to be an area still changing to some extent. However most of the changing was going on with VS 2015 and the early VS 2017 along with the SDKs. It seems to be pretty solid now with the latest updates.

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
  • I started a case on the MS' developer feedback platform. I believe that it is feasible to target Anniversary update with new toolset. I would like to do it for the reasons you mentioned. Thank you for your answer anyway :). – neonxc Nov 06 '18 at 18:19