Updating Nuget caused Exception Unhandled: System.TypeLoadException

Downgrade xamarin.forms and xamarin.forms.maps to v4.1.0.778454 in all projects.

I did it and worked perfectly


The issue is tracked on github and the issue only triggers only Visual Studio 2017 users. If you compile the app with Visual Studio 2019, the app runs fine with Xamarin.Forms 4.2.0.815419 (4.2.0 Service Release 2).

This is caused by a Mono change that made it into Xamarin.Android in VS2019.

System.Collections.Generic.Queue is available in

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll

and

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll

It's not available in

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll

So if any dll that relies on Queue is complied with VS2019, and run on VS2017, it will throw exception can't load Queue from mscorlib.

The Xamarin.Forms team tries now to implement Stack and Queue internally in XF code for VS 2017 Compatibility.

Until this is merged, the last Xamarin.Forms bit are compiled with VS2017 and work so fine with VS2017.