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.

Getting a XamlC error when trying to use common xmlns only in XAML without x:Name

See original GitHub issue

Description

I am creating custom controls in a library assembly. I have added XmlnsDefinition for the corresponding namespaces. If I use the controls in XAML and if I do not set x:Name, I get the following compile time error: XamlC error XFC0000: Cannot resolve type “http://schemas.mycompany.com/2022/xaml/maui:prefix:MyControl”. If I set x:Name in the page, where the controls are used – it works, if I use the controls in code behind in addition to XAML – it works.

Steps to Reproduce

  1. Rebuild the attached solution
  2. Observe the error: XamlC error XFC0000: Cannot resolve type "http://schemas.mycompany.com/2022/xaml/maui:prefix:MyControl" MauiXmlnsRepro.zip

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

N/A - compile-time issue

Did you find any workaround?

Setting x:Name in the page fixes it, but it is outside my control as a component vendor.

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
StephaneDelcroixcommented, Jun 8, 2022

The workaround pointed by @pictos works: adding a code reference to each assembly (not each type) solve the issue. But the intent of this workaround, and documentation, was to prevent linking for runtime-inflated Xaml. With Maui, Xaml Compilation is enforced for Release builds, and we could get rid of this requirement.

So, not a new error, but I’m still investigating if we can get rid of it…

1reaction
pictoscommented, Jun 7, 2022

Maybe this can help… Just a reminder, in order to use the custom-schema, generated by XmlnsDefinition you need to have some C# code that references the lib. More info here.

After adding _ = new RadButton(); _ = new RadGauge(); in the code (I added on the MauiProgram) I was able to run, ~but for some reason the RadioButton still fails, not sure if it’s because you have the same custom schema for two different assemblies~

i was adding RadioButton instead of RadButton, after fixing that it worked (: So I would say that isn’t a bug, but a limitation on custom XmlnsDefinition

Read more comments on GitHub >

github_iconTop Results From Across the Web

XamlC error XFC0000 : Cannot resolve type "Shield ...
Error : : XamlC error XFC0000 : Cannot resolve type "Shield" Steps to Reproduce Installed Xamarin Community Toolkit (v 1.1.0) in All projects ......
Read more >
The name does not exist in the namespace error in XAML
When you are writing your wpf code and VS tell that "The name ABCDE does not exist in the namespace clr-namespace:ABC".
Read more >
Getting error using RadComboBox control
I am sending you a link to the issue which might occur if the x: Name is not set: Getting a XamlC error...
Read more >
Another common mistake using Xamarin Forms (and XAML)
The only issue is that exception message could be better. Instead of “Property Content is null or is not IEnumerable” it could have...
Read more >
Schema Error Telerik Type cannot be Resolved
When I try to use the Telerik UI for .NET MAUI ComboBox component, I get the XamlC error XFC0000: Cannot resolve type "http://schemas.telerik.com/2022/xaml/maui ......
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