Could not load type 'Xamarin.Forms.Platform.UWP.FormsTimePicker'

Posted by: jared.fritsch on 16 October 2017, 7:12 am EST

    • Post Options:
    • Link

    Posted 16 October 2017, 7:12 am EST

    I’m trying to use the FlexGrid in Xamarin.Forms. I have added the C1.Xamarin.Forms.Grid NuGet package and all of its dependencies. Intellisense picks up the FlexGrid control for use in XAML and C#. I have also added ```

    FlexGridRenderer.Init();

    
    However, when I run the app on UWP, I get the error:
    Could not load type 'Xamarin.Forms.Platform.UWP.FormsTimePicker' from assembly 'Xamarin.Forms.Platform.UAP.
    
    Stack trace:
    System.TypeLoadException: Could not load type 'Xamarin.Forms.Platform.UWP.FormsTimePicker' from assembly 'Xamarin.Forms.Platform.UAP, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.
       at C1.Xamarin.Forms.Grid.Platform.UWP.FlexGridRendererCellFactory.GetNativeElement(View view, Element parent)
       at C1.Xamarin.Forms.Grid.Platform.UWP.FlexGridRendererCellFactory.CreateCellContent(GridCellType cellType, GridCellRange range, Object cellContentType)
       at C1.UWP.Grid.GridCellFactory.CreateCellContent
    
    
    I'm trying to show a very basic grid at this point.
    
    

    <c1:FlexGrid

    x:Name=“TheGrid”

    AutoGenerateColumns=“True” />

    
    

    TheGrid.ItemsSource = new List() {

    “test1”, “test2”

    };

    
    This may have something to do with using a Shared Project vs a PCL when creating the Xamarin.Forms solution. I followed these steps initially in an existing Shared Project and I received the error above. I then followed these steps in an existing PCL project and it seemed to work just fine. After that, I created a brand new Shared Project, followed the steps, and got the same error.
  • Posted 17 October 2017, 1:05 am EST

    Hi Jared

    I can reproduce the issue. I’ll take a look with the developers to see if we can come up with a fix or workaround.

    Thanks

    Kelley

  • Posted 17 October 2017, 7:04 am EST

    I did discover a workaround for the problem. Apparently this is something that was introduced in Xamarin.Forms 2.4. I rolled back to 2.3.4.270, and this problem went away. We’ll keep researching the issue.

  • Posted 18 October 2017, 12:32 pm EST

    Thanks, Kelley! Appreciate the quick response. I’ll rollback my Xamarin.Forms version for now.

  • Posted 23 October 2017, 4:00 am EST

    Kelley - any update you can provide on this?

    Does C1 provide any pre-release versions that we could maybe test with either via NuGet or some other source?

  • Posted 23 October 2017, 5:32 am EST

    Hi Jared

    I have a pre-release build here which you can try locally:

    http://publicfiles.componentone.com/XamarinEdition/C1Xamarin_2.4.20172.195.zip

    I believe this should fix it. This version should have better support for Xamarin.Forms 2.4 and .NET Standard in general.

    Thanks

    Kelley

  • Posted 24 October 2017, 1:42 am EST

    The pre-release build you provided seems to work great! Everything is working as expected so far.

    Thanks again for your timely responses. Much appreciated!

  • Posted 25 October 2017, 1:27 am EST

    Hi Jared

    QA passed that same build so it should now be available via NuGet as well.

    Kelley

  • Posted 25 October 2017, 2:04 am EST

    Thanks Kelley!

    I just tried updating my project to the version you just pushed out (2.4.20172.195). It looks like C1.Xamarin.Forms.Grid has a dependency to C1.CollectionView which has a dependency to System.Linq.Parallel. Upon updating, I receive an error saying:

    Could not install package ‘System.Linq.Parallel 4.3.0’. You are trying to install this package into a project that targets ‘.NETPortable,Version=v4.5,Profile=Profile259’, but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    That PCL profile in the error is for Xamarin. I have to apologize. When I tested it with the pre-release build you provided, it actually only installed 2.4.20172.195 into my UWP project, it didn’t install it into the PCL project as well (leaving my PCL at 2.3.20172.189). I’m not sure why I missed that or why it didn’t give me the error then. I would have mentioned this sooner had I saw it.

    What’s interesting is that 2.3.20172.189 also has that same dependency to System.Linq.Parallel and that seems to work just fine.

    If you try updating to the latest version with a PCL Xamarin.Forms project, do you see that same error I mentioned above? Or is this just me?

  • Posted 25 October 2017, 2:10 am EST

    To clear up some confusion…I have been testing this with both Shared Projects and PCL based Xamarin.Forms projects. The latest update (2.4.20172.195) is working well with my Shared Project. It is not however, working with my PCL project (as detailed above).

  • Posted 25 October 2017, 2:41 am EST

    Hi Jared

    I don’t see the same problem here. Does it work from a brand new project? Also does it work if you manually install System.Linq.Parallel from NuGet?

  • Posted 25 October 2017, 8:52 am EST

    Looks like it installed just fine with a brand new project. I noticed my new project uses Profile 111 whereas my existing projects uses Profile 259. No reason (for us) it needs to be 259. Must have been defaulted to that when I created it sometime ago.

    More info for those interested:

    https://www.danrigby.com/2014/05/14/supported-pcl-profiles-xamarin-for-visual-studio-2/

    Thanks!

  • Posted 26 October 2017, 12:52 am EST

    Hi Jared

    With build 195 (and the coming v3 release) we targeted .NET Standard 1.1 so that we could have better compatibility with Xamarin.Forms 2.4 (which also supports .NET Standard) while still supporting the current default Xamarin.Forms template’s PCL profile 111. Unfortunately there isn’t a one size fits all solution to .NET Standard support and PCL’s right now (as your linked article shows), but hopefully this becomes less of an issue in tre future as Microsoft places more emphasis on migrating users from PCL to .NET Standard libraries.

    Kelley

  • Posted 26 October 2017, 2:04 am EST

    Sounds good. I think that is the right path. I imagine a lot of projects will be held up by third parties that don’t offer .NET Standard support. Good to get on the bandwagon as soon as possible.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels