Sharpnado.Shadows
Sharpnado.Shadows copied to clipboard
Error XFC0000: Cannot resolve type "shades:Shadows"
- Sdk version: iOS 11/Android SDK 21
- Xamarin.Forms: 4.8+
I installed the NuGet and added a shadow to a label, but got the next compilation error on build:
Error XFC0000: Cannot resolve type "shades:Shadows"
Steps to reproduce the behavior:
- Install nuget
- Add shadow namespace inside xaml
- Add shadow
- Try to build
- See error
Source of the page:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:shades="http://sharpnado.com"
x:Class="FailsInShadowsNuget.MainPage">
<shades:Shadows>
<Label FontSize="16" Padding="30,24,30,0">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="Learn more at " />
<Span Text="https://aka.ms/xamarin-quickstart" FontAttributes="Bold" />
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
</shades:Shadows>
</ContentPage>
Cannot replicate your issue
@byme8 xmlns:shades="http://sharpnado.com" - change this to xmlns:shades="clr-namespace:Sharpnado.Shades;assembly=Sharpnado.Shadows"
@themronion @byme8 how do you end up with this issue ? what IDE are you using (including precise version number) ?
@roubachof I didn't even try to reproduce this issue, i just recommended the way i declare your plugin in xamls)
it's the new namespace attribute, it should work this way in the latest version
@themronion, with xmlns:shades="clr-namespace:Sharpnado.Shades;assembly=Sharpnado.Shadows"
everything works as expected. Thanks!
@roubachof, I am using Microsoft Visual Studio Community 2019 Version 16.7.6. Also tested on VS For Mac 8.7.8.4 and got the same compilation error.
@roubachof
how do you end up with this issue?
I just installed the package and VS resolved namespace as xmlns:shades="http://sharpnado.com"
. That's all.
Which version of XF please ?
Same for me on version XF 4.8.0.1451 the syntax only shows xmlns:shades="http://sharpnado.com" when implementing in XAML
@dansiegel do you have an idea what is causing this. I could replicate it also. If you add as a nuget package and you add a Shadows, it is fine with the intellisense but you end up with a compile error...
I'm not sure what's causing this, I know that you have your preferred prefix as sho
but I tried changing the xmlns to sho
and got the same result. It seems very similar to xamarin/xamarin.forms#8451 but I believe that has to do with a project not having been compiled yet which wouldn't quite be the same issue when you're working with a nuget...
Perhaps someone on the Forms team can provide some input here... to me it looks like a problem with XamlC @redth @StephaneDelcroix @pureween
thanks to @pictos here is the deal:
To consume types from the custom namespace schema, the XAML compiler requires that there's a code reference from the assembly that consumes the types, to the assembly that defines the types. This can be accomplished by adding a class containing an Init method to the assembly that defines the types that will be consumed through XAML:
from: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/custom-namespace-schemas#consuming-a-custom-namespace-schema
So for the namespace schema to work, you need to call initializer from App.xaml.cs like this:
public App()
{
InitializeComponent();
Sharpnado.Shades.Initializer.Initialize(false);
Sharpnado.Tabs.Initializer.Initialize(true, true);
}
Giving the control a name solved it for me, "x:name" to the shadow control
Yup cause it generates a code reference to the assembly.