-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Getting a XamlC error when trying to use common xmlns only in XAML without x:Name #7503
Comments
Looks like a linking issue. Adding x:Name creates a ref that prevents linking out. I’ll investigate further |
repro with vs main build(32606.310.main) |
not a trimming/linking option. |
Maybe this can help... After adding i was adding |
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... |
@StephaneDelcroix if you can improve on this issue that would be fantastic. I have seen a few projects where people make use of the .NET MAUI Community Toolkit via library projects and without C# directly accessing the components they need they see this issue. I would be more than happy to provide any details/assistance on this. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Also get this if use a Map with no other properties set. e.g.:
|
I tried the original example (upgraded to .NET 7): <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
x:Class="MauiApp14.MainPage">
<Grid>
<telerik:RadButton></telerik:RadButton>
<telerik:RadGauge></telerik:RadGauge>
</Grid>
</ContentPage> And XamlC emits this in private void InitializeComponent()
{
RadButton radButton = new RadButton();
RadGauge radGauge = new RadGauge();
Grid grid = new Grid();
MainPage mainPage;
NameScope value = (NameScope)(NameScope.GetNameScope(mainPage = this) ?? new NameScope());
NameScope.SetNameScope(mainPage, value);
grid.Children.Add(radButton);
grid.Children.Add(radGauge);
mainPage.SetValue(ContentPage.ContentProperty, grid);
} Which looks right to me. But then I get a crash at runtime because the handler is missing:
So yeah, there might be something fundamental here. Why is |
Oh, Debug mode crashes in the same way. Does someone have a more recent repro? I am not getting a XamlC error using the latest stable MAUI. |
Hi @vvgeorgiev. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
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
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
The text was updated successfully, but these errors were encountered: