DottorPagliaccius / Xamarin-Custom-Controls

in progress
MIT License
96 stars 34 forks source link

Type accordion:AccordionItemView not found in xmlns clr-namespace... #20

Closed michaelrbrown closed 6 years ago

michaelrbrown commented 6 years ago

I have tried everything. Downgraded nuget versions, etc. I am running xamarin forms 2.5.1.444 and 1.0.8 of your control. It builds fine, just throws this error (see below) at runtime.

Type accordion:AccordionItemView not found in xmlns clr-namespace:Xamarin.CustomControls;assembly=Xamarin.CustomControls.AccordionView

<?xml version="1.0" encoding="UTF-8" ?> <ContentPage x:Class="PTS.Mobile.Views.Product_Details.ProductDetails" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:accordion="clr-namespace:Xamarin.CustomControls;assembly=Xamarin.CustomControls.AccordionView" xmlns:dataForm="clr-namespace:Syncfusion.XForms.DataForm;assembly=Syncfusion.SfDataForm.XForms" xmlns:ffImageLoading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" xmlns:sfgrid="clr-namespace:Syncfusion.SfDataGrid.XForms;assembly=Syncfusion.SfDataGrid.XForms" xmlns:transformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations">

`

`
DottorPagliaccius commented 6 years ago

Hi @michaelrbrown.

Uhm... very strange. What PCL profile (or .net standard version) do you use?

Have you tried to put this

[assembly: XamlCompilation (XamlCompilationOptions.Compile)]

over your namespace or page class? (ref: https://docs.microsoft.com/it-it/xamarin/xamarin-forms/xaml/xamlc)

Let me know.

michaelrbrown commented 6 years ago

Hi @DottorPagliaccius,

I think I figured it out. This may be the cause of the other issue in a previous thread as well. I adopted a solution that was worked on by other devs. Come to find out they had a class called "AccordionView" buried in a controls folder. Although it had a different namespace it may have collided somehow. ReSharper and Roslyn didn't catch any dependency or collision issues so it's strange for sure. It compiled fine as well. I was able to fix by just pulling over your files into my solution instead of using the nuget package. It's not ideal but works for now. Thank you so much for getting this control out there for us busy/lazy people to consume! I was about to just roll my own until I found yours, which in my opinion is the only one out there that is complete for enterprise use. So thank you for this and the quick response! I will see what I can do to contribute!

PostImpatica commented 6 years ago

I kept getting the exact same error. I tried changing project names, assembly names, object names, everything under the sun thinking something must be conflicting. I even tried creating new projects from scratch, but no matter what, the exact same error.

After I brought: AccordionItemView.xaml AccordionRepeaterView.cs AccordionView.cs StateButton.xaml into my own project and renamed the namespaces everything works great.

michaelrbrown commented 6 years ago

@DottorPagliaccius I am using .netstandard 2.0.1. @helzgate renaming did it for me. There has to be something small you are missing. Try ensuring the xaml compiliation attribute is there as said above. Also ensure the namespaces / class names match exactly in the xaml headers. There should be a statebutton.cs you didn't list but maybe you have it?

DottorPagliaccius commented 6 years ago

There has to be something small you are missing

I think so :/ But sadly I can't reproduce this issue. Maybe there is something wrong with nuspec files?

DottorPagliaccius commented 6 years ago

It happens only when I comment [assembly: XamlCompilation(XamlCompilationOptions.Compile)] in App.xaml.cs, frankly I can't understand why it's behaving like this :/ I will try recreating project and nuget package, I'll let you know

michaelrbrown commented 6 years ago

I was able to get it working perfectly with a Xam Forms app I am using for Parker Hannifin. It's worth the effort to fix probably the best accordion control I have seen or used, for my needs anyway. You can even load data when the sections expand async which allows me at least to work with dozens of endpoints pulling data from an external service. Wish I could help you more I spent days on trying the nuget package then gave up and pulled the code in completely, which then showed me some collision issues I had with another accordion control.

2018-05-30_22-10-40

DottorPagliaccius commented 6 years ago

Thank you @michaelrbrown ;)

It seems to be a linker problem, that's why it works precompiling XAML. I've recreated the project, added Preserve attribute to every class, prayed Cthulhu, etc. Now it should work.

Please try version 1.1.5. If it still not working, please try putting this line new Xamarin.CustomControls.AccordionItemView(); in appdelegate/mainactivity. It seems the linker strips away code that is not referenced outside xaml, e (it works even if you reference it in the using list, something like using ItemView = Xamarin.CustomControls.AccordionItemView;). This behaviour is really strange, since it happens even when I choose "Don't link" in ios project.

Let me now ;)

michaelrbrown commented 6 years ago

No problem @DottorPagliaccius,

I will see if I can create a new project and test the nuget package. Unfortunately, the solution I am in now is production and released in app store and google play so I don't want to test this there. As I stated, it's working perfectly fine for me now by just bringing the code into my project and not going nuget route.

Give me a day or so I will try the latest nuget in a sample project and let you know. Appreciate you working on this and getting it fixed. Super nice control and work!

V/R, Michael