Getting a XamlC error when trying to use common xmlns only in XAML without x:Name
See original GitHub issueDescription
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
- Rebuild the attached solution
- 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:
- Created a year ago
- Reactions:3
- Comments:12 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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…
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 theRadioButton
still fails, not sure if it’s because you have the same custom schema for two different assemblies~i was adding
RadioButton
instead ofRadButton
, after fixing that it worked (: So I would say that isn’t a bug, but a limitation on customXmlnsDefinition