MicrosoftDocs / windows-dev-docs

Conceptual and overview content for developing Windows apps
Creative Commons Attribution 4.0 International
696 stars 1.2k forks source link

WinUI in C++/WinRT BlankApp Confusion #2643

Closed M-Rabel closed 2 years ago

M-Rabel commented 4 years ago

Hi,

While your "Additional steps for a C++/WinRT project" section (on https://docs.microsoft.com/en-us/windows/apps/winui/winui2/getting-started, see below) is technically working, however I (and probably others as well) got confused by the following issue: I added (the NuGet-Packet etc. and) the include directives as indicated (into the 'C++/WinRT - Blank App' template), but then thought "well, 'winrt/Microsoft.UI.Xaml.Controls.Primitives.h' is included already" (from the template), so I can delete that line to make my pch.h a little cleaner. The problem however is, that the template uses include <...>, which, using the Visual-Studio 2019 default-setup, loads the header from the the SDK, which obviously is not updated by running winrt on the new references (and also pulls in the 'winrt/Microsoft.UI.Xaml.Controls.h' header from there). Making things even worse, Visual Studio displays, when hovering the include and pressing F12, the locally generated header (which is of course correct). So from within VS all seems fine, but the compiler only pulls in the SDK headers, so one gets a compiler-error as explained in this blog post: https://devblogs.microsoft.com/oldnewthing/20190530-00/?p=102529.

Best Regards, Martin


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Karl-Bridge-Microsoft commented 2 years ago

The WinUI and WinApp SDK docs have seen numerous updates and improvements. Closing this issue due to age. Please open a new issue if this is still a concern.