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

Custom Control not working in WinUI 3 preview 3 (desktop) #3657

Open
wbokkers opened this issue Nov 19, 2020 · 14 comments
Open

Custom Control not working in WinUI 3 preview 3 (desktop) #3657

wbokkers opened this issue Nov 19, 2020 · 14 comments
Labels
area-Tooling area-XamlCompiler bug Something isn't working product-winui3 WinUI 3 issues team-Markup Issue for the Markup team

Comments

@wbokkers
Copy link

wbokkers commented Nov 19, 2020

Describe the bug
After adding and using a Custom Control, I get a XAML error:
WMC0610, The XAML Binary Format (XBF) generator reported syntax error '0x03e9'

Steps to reproduce the bug

  1. Get and install the WinUI 3 preview 3 templates
  2. Open Visual Studio 2019 Community Preview (Version 16.9.0 Preview 1.0)
  3. Create an empty WinUI (C#) project for Desktop
  4. Add a custom control.
  5. Use the custom control in MainWindow.xaml
  6. Try to run the app (F5)

Expected behavior
The project should compile and run.

Screenshots
image

image

Version Info

NuGet package version:
[Microsoft.WinUI 3.0.0-preview3.201113.0]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
May 2020 Update (19041) Yes

|

Device form factor Saw the problem?
Desktop Yes

Additional context
I can compile and run when moving the XAML namespace declaration of the custom control style to the ResourceDictionary, but then I get this runtime error:
image

In the output window I see the following errors:
D:\a\1\s\dev\MRTCore\mrt\Core\src\MRM.cpp(276)\MRM.dll!7C1ADEA1: (caller: 7C1AF6A8) ReturnHr(1) tid(65e4) 80073B17 NamedResource Not Found.
D:\a\1\s\dev\MRTCore\mrt\Core\src\MRM.cpp(403)\MRM.dll!7C1AF6C5: (caller: 571BBF9E) ReturnHr(2) tid(65e4) 80073B17 NamedResource Not Found.
D:\a\1\s\dev\MRTCore\mrt\Core\src\MRM.cpp(755)\MRM.dll!7C1AF8E0: (caller: 571BBF9E) ReturnHr(3) tid(65e4) 80073B17 NamedResource Not Found.
Exception thrown at 0x76AE9AB2 (KernelBase.dll) in App1.exe: WinRT originate error - 0x80073B17 : 'NamedResource Not Found.'.
onecore\com\combase\winrt\error\restrictederror.cpp(1016)\combase.dll!768623ED: (caller: 767C5126) ReturnHr(1) tid(65e4) 8007007E The specified module could not be found.
Exception thrown at 0x76AE9AB2 in App1.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x02DDE268.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Nov 19, 2020
@stevenbrix
Copy link
Contributor

Adding @alwu for FYI.

what does the controls namespace map to? this worked fine for me locally, although I did hit the first chance exception you see. You can disable this exception, and your app should still run:

image

@stevenbrix stevenbrix added team-Markup Issue for the Markup team product-winui3 WinUI 3 issues and removed needs-triage Issue needs to be triaged by the area owners labels Nov 19, 2020
@wbokkers
Copy link
Author

This is my solution structure:
image

There is no controls namespace. It's called local2 and it maps as follows:
xmlns:local2="using:App1.Controls"

@wbokkers
Copy link
Author

wbokkers commented Nov 20, 2020

Not breaking on the exception works for me. But I can't leave the namespace declaration in the control.
So, I need to specify it as follows:
image

The auto generated code (below) does not work:
image

@stevenbrix
Copy link
Contributor

Just so I understand this properly, you're saying that the auto-generated code results in the following compiler error?

image

And you're able to workaround it by moving the local2 namespace declaration to the top of the file?

@wbokkers
Copy link
Author

Yes, exactly!

@stevenbrix
Copy link
Contributor

Thanks @wbokkers, I'm glad you have a workaround, even though I'm sure it's annoying.

Do you know if this is a regression in WinUI3, or if this happens in WinUI2.x as well?

@wbokkers
Copy link
Author

Never saw this happen with UWP, but I never tested with WinUI2, unfortunately.

@stevenbrix
Copy link
Contributor

@wbokkers I just tested this with a UWP project and it does look like it's happening, although maybe there was some regression in UWP that was missed?

@KonstantinKhabarlak
Copy link

The problem is still present in 1.0 release. The proposed workaround also works

Not breaking on the exception works for me. But I can't leave the namespace declaration in the control. So, I need to specify it as follows: image

The auto generated code (below) does not work: image

@clembu
Copy link

clembu commented Dec 9, 2022

Still relevant for 1.2

@iamhazel
Copy link

iamhazel commented Mar 30, 2023

Still relevant for 1.3 Preview1

@TekuSP
Copy link

TekuSP commented Jun 23, 2023

Can someone explain to me the workaround?
I end up on
image

@TekuSP
Copy link

TekuSP commented Jun 23, 2023

If I ignore exception I end with
image

@duncanmacmichael duncanmacmichael added the bug Something isn't working label Nov 3, 2023
@bpulliam bpulliam removed this from the WinUI 3.0 milestone Feb 29, 2024
@ruimaciel
Copy link

I've just experienced this exact problem after adding a ContentDialog to an existing WinUi3 project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tooling area-XamlCompiler bug Something isn't working product-winui3 WinUI 3 issues team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

9 participants