cppwinrt: [regression] Apps using DesktopWindowXamlSource start breaking in 2.0.201026.4 nuget
Before 2.0.201026.4, a Win32 app could do
#include <winrt/Windows.UI.Xaml.Hosting.h>
// ...
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource dwxs{}
Beginning in 2.0.201026.4, apps will now get a
error C2039: 'DesktopWindowXamlSource': is not a member of 'winrt::Windows::UI::Xaml::Hosting'
For UWP apps, they can reference the Desktop Extension SDK which contains the Windows.UI.Xaml.Hosting contract. However, I’m not sure if Win32 apps are able to do that (which is the whole purpose of the hosting apis, i.e. to be used from win32 apps).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (11 by maintainers)
It pretty much just works™️ for me. Any specific issue you’re hitting? We can take this offline (on Discord) if you want to, to avoid cluttering people’s inboxes.
Install the cppwinrt nuget in every project that needs to use cppwinrt
This is not a C++/WinRT bug. What’s happening in the repro is that the include path is set to multiple Generated Files folder from multiple different projects, meaning that the same headers exist multiple times on the include path. This is unsupported.
Because the include paths are mixed, the compiler picks the header from MyApp that doesn’t include the Desktop extension and therefore it can’t find the types. The fix for this is to sort out the include paths. A project should never include the Generated Files folder from a different project in its own include path.
I am unable to repro with the above steps. Following up offline.
@jlaanstra simplified repro:
4>E:\Xaml-Islands-Samples\Samples\Win32\SampleCppApp\XamlBridge.h(18,40): error C2039: 'DesktopWindowXamlSource': is not a member of 'winrt::Windows::UI::Xaml::Hosting' 4>E:\Xaml-Islands-Samples\obj\Win32\Debug\MyApp\Generated Files\winrt\Windows.UI.Xaml.Hosting.h(166): message : see declaration of 'winrt::Windows::UI::Xaml::Hosting'