question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inheriting from a XAML page within the same project fails to compile in C++/WinRT with /std:c++20

See original GitHub issue

Describe the bug After upgrading to VS 17.0 Preview 2, inheriting from another XAML page within the same project results in a compile error when combined with /std:c++20 or /std:c++latest

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create a new UWP project using C++/WinRT
  2. Set the langage version to C++ 20 or latest in project settings
  3. Make MainPage unsealed in the IDL
  4. Create a new XAML page in the project (named BlankPage in the rest of these steps)
  5. Remove or rename the MyProperty property from BlankPage.cpp, BlankPage.h and BlankPage.idl to avoid conflicts with the base class
  6. Make that page inherit from MainPage from IDL: runtimeclass BlankPage : MainPage (don’t forget import "MainPage.idl";)
  7. Add #include "MainPage.h" to BlankPage.h
  8. Update BlankPage.xaml to declare a root object of type local:MainPage instead of Page
  9. Compile the project
  10. Observe the 'to_abi': no matching overloaded function found error

Expected behavior The code should compile correctly and run.

Screenshots image

Version Info

NuGet package version: This issue happens whether WinUI 2 is used or not.

Windows app type:

UWP Win32
Yes Yes (system XAML islands)
Windows version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context This happens with the Windows SDK version 22000.100, I think it needs to use the v143 toolset as well.

Developer Community issue: https://developercommunity.visualstudio.com/t/Inheriting-from-a-XAML-page-within-the-s/1491603?entry=myfeedback

Sample repro project: BlankApp1.zip (edit 2020-08-02: updated the zip, I somehow managed to upload a zip attempting to use a cppwinrt version that didn’t exist on NuGet)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
ChrisGuzakcommented, Aug 2, 2021

for MS folks this is http://task.ms/35009721

0reactions
sylveoncommented, Jan 31, 2022

I had to do a clean build to force the XAML codegen to trigger again, merely upgrading the SDK still used the old codegen - my bad! The issue is resolved now, thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot use an Xaml component from a C# WinRT ...
Open an Xaml page in one of Windows Terminal projects (we will use TerminalPage.xaml from TerminalAppLib project as an example). Add the ...
Read more >
Troubleshooting C++/WinRT issues - UWP applications
This error can occur when you declare one base class in your IDL and a different base class in your XAML markup. Loading...
Read more >
How can I use XAML custom control in Windows Runtime ...
Hi! Though I have another issue, by reducing the sample's complexities, I hit to an error that cannot refer XAML control in Windows...
Read more >
Is there a way to pass a base page to be inherited ...
Hi. the XAML pages aren't inheriting from each other. XAML is a markup language, not code. The way you can approach your pages...
Read more >
Effective C++/WinRT for UWP and Win32 - YouTube
C++/ WinRT is designed to give C++ developers uncompromising ... a XAML application in standard C++ and provide tips and guidance on how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found