dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.09k stars 1.73k forks source link

Investigate and fix XFC0000 errors for external assemblies #9781

Open jfversluis opened 2 years ago

jfversluis commented 2 years ago

Description

We've seen this error a lot with the Xamarin Community Toolkit. Now with .NET MAUI Maps we want the Map to appear as being "in the box" with .NET MAUI and let people just use <Map /> without having to add an extra XML namespace. However, because the Map is in another assembly, the assembly won't get loaded resulting in this error.

Visual Studio will throw a XFC0000 error with XamlC and potentially during runtime another error since it won't load the external assembly.

Ideally we fix this for all external assemblies, but at the very least we should do it for Maps.

In earlier investigations (for Forms) I thought the source of this was here: https://github.com/xamarin/Xamarin.Forms/blob/caab66bcf9614aca0c0805d560a34e176d196e17/Xamarin.Forms.Xaml/XamlParser.cs#L340

Steps to Reproduce

  1. Create a new .NET MAUI Project
  2. Install .NET MAUI Maps package
  3. Add <Map /> to your XAML
  4. Add UseMauiMaps() and potentially a Google Maps API key if needed, this error happens on both iOS and Android
  5. Build the app, a XCF0000 should come up

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

All

Did you find any workaround?

Add xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps" to the root of your XAML and use the map as <maps:Map /> makes it work.

Relevant log output

No response

juwens commented 1 year ago

We have this issue too, workaround works fine.

Would be handy to know: is the culprit is in the community-toolkit or in the xaml-compiler