0
votes

Xamarin project using Prism project template - initial project (with nothing added) builds and runs fine for Android 7.1 emulator. Add Realm NuGet package and the app builds and deploys, but crashes on launch with the following:

Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
This might be due to an invalid debug installation.
A common cause is to 'adb install' the app directly instead of doing from the IDE.

This seems to be a fairly common problem encountered when using Entity Framework and there are a few posts on the internet on it, but I have not found any posts where it occurred due to adding the Realm package. I have tried the suggested solutions that I have come across - use Packages.config rather than PackageReference (I was anyway), change linker option to 'Sdk and User assemblies', add <NoWarn>$(NoWarn);NU1605</NoWarn> to Android.csproj file, add <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.3.0" /> to csproj file - none of these have made any difference at all.

Anybody come across this, solved it, or have any suggestions? It has stopped me dead in my tracks.

1

1 Answers

0
votes

i solved this issue after 8 days. My solution is not from the prettiest but works, I simply rollbacked logic of loading packages by reference in .csproj back to packages.config only in Android. Make sure you dont only switch settings in NuGet Manager, but also delete packageReferences, create "packages.config" only with basic markup

<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>

Then deleting all packages saved in \Users{user}.nuget\packages, clearing cache. Then install needed packages one by one {i have issues on installing all dependencies, so i install them manually too} Tho I don´t know cause of this issue nor the proper solving. Try that at blank project at first and let me know if that helps. Good luck.