Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation to a Blank Page in Class library project leads to Exception in UWP #4618

Closed
syncsiva opened this issue Mar 19, 2021 · 6 comments
Closed
Labels
product-winui3 WinUI 3 issues team-Markup Issue for the Markup team team-Reach Issue for the Reach team v0.5 Issues introduced in the Project Reunion 0.5 prerelease

Comments

@syncsiva
Copy link

Describe the bug
Navigation to a Blank Page in Class library project leads to Exception

Steps to reproduce the bug
ReunionBlackAppUWP.zip

Steps to reproduce the behavior:

  1. Just open the sample and run, you will get xaml parse exception
    Exception thrown: 'Windows.UI.Xaml.Markup.XamlParseException' in ClassLibrary1.dll
    An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in ClassLibrary1.dll but was not handled in user code
    XAML parsing failed.
  2. Its just a blank app and a class library with blank winui page.

Expected behavior
Should work without any exception. It works fine with WinUI3 Preview4 and facing exception only after updating to Project reunion.

Screenshots
image

Version Info
Microsoft.ProjectReunion -> Version="0.5.0-prerelease
Visual Studio : VS 2019 16.10 Preview 1.0
Microsoft Windows Version 20H2 (OS build 19042.867)

Additional context
It works fine with WinUI3 Preview4 and facing exception only after updating to Project. Any workaround is very helpful.

@syncsiva syncsiva changed the title Adding Blank Page in Class library project leads to compilation error in UWP Navigation to a Blank Page in Class library project leads to Exception in UWP Mar 19, 2021
@mrlacey
Copy link
Contributor

mrlacey commented Mar 19, 2021

@syncsiva In your example, you've added a UWP (WInUI 2) blank page to the ClassLibrary but then are trying to compile it with the WinUI 3 toolchain.
This means that the class you've defined (in BlankPage1.xaml.cs) is based on Windows.UI.Xaml.Controls.Page but the code that is generated by the compiler create a partial file that inherits from Microsoft.UI.Xaml.Controls.Page.

If you update BlankPage1.xaml.cs like this it will compile:

partial screenshot showing the below code snippet

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.Foundation;
//using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

To avoid this in future, make sure you add a Blank Page (WinUI) to your WinUI 3 projects.

File New Item dialog showing the 'Blank Page (WinUI)' option

It would be really great if tooling could detect this and provide a more helpful/specific error message.

@syncsiva
Copy link
Author

@mrlacey I have added Black Page (WinUI) only. Initially i have added BlankPage1 based on Windows.UI.Xaml.Controls.Page and later re-attached the correct the sample. Please refer below sample where exception thrown when we navigate to the page in class library project.

Sample app:
App8.zip

Screen shot:
image

@mrlacey
Copy link
Contributor

mrlacey commented Mar 21, 2021

@syncsiva Having investigated, this looks to be an issue with the code that WinUI3 generates as part of compiling the XAML files, so I have logged a bug there.

@syncsiva
Copy link
Author

@mrlacey It was worked when i use WinUI3 Preview4 project template and not working after upgrading to Project Reunion 0.5 Preview.

@andrewleader andrewleader transferred this issue from microsoft/WindowsAppSDK Mar 22, 2021
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Mar 22, 2021
@StephenLPeters StephenLPeters added v0.5 Issues introduced in the Project Reunion 0.5 prerelease team-Markup Issue for the Markup team product-winui3 WinUI 3 issues labels Mar 23, 2021
@syncsiva
Copy link
Author

Any workaround solution to the problem would be greatly appreciated!

@pratikone pratikone added team-Reach Issue for the Reach team and removed needs-triage Issue needs to be triaged by the area owners labels Oct 14, 2022
@bpulliam
Copy link
Contributor

UWP is no longer supported by WinUI 3. If you can repro the issue on current builds without UWP, please reactivate or open a new issue.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product-winui3 WinUI 3 issues team-Markup Issue for the Markup team team-Reach Issue for the Reach team v0.5 Issues introduced in the Project Reunion 0.5 prerelease
Projects
None yet
Development

No branches or pull requests

5 participants