Introduction
Building Xamarin Forms apps using .Net Standard 2.0 is still pretty much new to industry, we are just started to learn how differently we have to configure Xamarin setting to get it working when compared to PCL based projects.
I was building a Xamarin Forms based App using Microsoft’s Entityframeworks SQlite to store app’s data. Entity framework using sqlite is an obvious choice when it comes to building App using .Net Standard 2.0
Simulator
Works well on pretty much on all simulators without any issue, all read/write operations works well.
Issue – Physical Device
App crashes on physical device, when tried to read or write data from the SQlite database
Error
System.TypeInitializationException: The type initializer for ‘Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions’ threw an exception. —> System.InvalidOperationException: Sequence contains
no matching element
Resolution
Change linker behavior to “Don’t Link”
any solution?
Change linker behavior to “Don’t Link”
That is never a solution for production builds. But you can specify specific assemblies to be skipped while linking, you can refer to this:
https://docs.microsoft.com/en-us/xamarin/android/deploy-test/linker