Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Xamarin Forms to .Net Standard 2

I am attempting to convert my Xamarin project to use .net Standard 2.

  • I have added the .net standard 2 library
  • I have installed all the nuget packages that previously existed in my pcl library. (all build fine)
  • Then I removed the pcl and added the std library

However when I build I get a few compile time exceptions:

  • Could not load assembly 'IdentityModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
  • Could not load assembly 'XLabs.Forms, Version=2.0.5782.12218, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?

Those ddl indeed does not exist in the Android bin folder. If I copy the dlls in manually the build error goes away.

I am not that familiar with the new .net standard stuff to know if these libraries are maybe not being copied over because of incompatibilities.

How do I fix this?

EDIT: The nuget packages above is only added to the common std and pcl library not the Android 1. This worked with the pcl version so I assumed similar behavior with the std version. I had to install it into the android version to make it work. Why was necessary in the std and not the pcl?

like image 573
Murdock Avatar asked Oct 29 '17 14:10

Murdock


People also ask

Is .NET 5 compatible with .NET standard 2?

NET 5 and all future versions will continue to support . NET Standard 2.1 and earlier.

Is .NET standard 2.1 compatible with .NET framework?

You cannot consume a . Net Standard 2.1 assembly in any . Net Framework Version because the . NET Framework (even the last ever version, 4.8) does not implement .

How do I upgrade Xamarin?

Go to Tools > Extensions and Updates... and click on the Installed list to check that the NuGet Package Manager for Visual Studio is at least version 2.8. 5. If it is older, click on the Updates list to download the latest version. Once you've updated the NuGet package to Xamarin.


1 Answers

You need to add the following NuGet packages to your Xamarin.Android project:

  • IdentityModel v1.0.0.0

  • XLabs.Forms v2.0.5782

I'm not sure why the PCL implementation worked without these packages in your Xamarin.Android project. Likely, the package creators are using Bait and Switch with the netstandard implementation.

like image 175
Brandon Minnick Avatar answered Oct 01 '22 09:10

Brandon Minnick