Description
Describe the bug
Internal bug https://task.ms/36925415
App.xaml.cpp is just activates the MainWindow which is exactly what it does out of the box. I attempted to put the page navigation code in there as documented but didn't work. Now MainWindow.xaml had a named <Frame x:Name="rootFrame Loaded="Loaded"/>
In the Loaded Event for the Frame I am calling rootFrame().Navigate(xaml_typenameComponent::BlankPage(), *this);
In either case I get an exception thrown:
Exception thrown at 0x00007FFB4621466C (KernelBase.dll) in CloudView.exe: WinRT originate error - 0x80004005 : 'Cannot locate resource from 'ms-appx:///BlankPage.xaml'.'.
This is a project added as a WinUI3 Runtime Component inside the Solution. My production code is in a Separate solution and has the same problem.
I tried the same thing using the Windowing Sample cpp-winui from the WindowsAppSDK-Samples.git repo. It works there. The difference is that this uses a separate Packaging Project. The current SDK integrates the packaging into the App.
Steps to reproduce the bug
-
Create a new Solution/Project using the "Blank App, Packaged (WinUI 3 in Desktop), Default names are fine. Don't check Solution in same folder
-
Add a New Project to the Solution using the "Windows Runtime Component (WinUI 3)" template. Default names are fine.
-
Add a New Item to the RuntimeComponent1 Project, using the "Blank Page (WinUI 3)" template. Default names are fine.
-
Build the RuntimeComponent1. Debug, x64 is what I used.
-
Add a Reference in App1 to RuntimeComponent1. Right click>Add>Reference...
-
Edit MainWindow.xaml and make it look like this:
-
Edit MainWindow.xaml.h.
Add the following #includes above #include "MainWindow.g.h"
#include <winrt/RuntimeComponent1.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
Add the following Loaded Method
void MainWindow::Loaded(Windows::Foundation::IInspectable sender, Microsoft::UI::Xaml::RoutedEventArgs const& e)
{
rootFrame().Navigate(xaml_typename < RuntimeComponent1::BlankPage>(), *this);
} -
Edit MainWindow.xaml.cpp and remove the reference to myButton() in the myButton_Click Event.
-
Build and run App1. You will get the exception.
Expected behavior
No response
Screenshots
No response
NuGet package version
1.0.0-preview3
Packaging type
Packaged (MSIX)
Windows version
Windows 11 (22000)
IDE
Visual Studio 2022
Additional context
No response