Search code examples
xamarin.formsxamarin.androidcastle-windsor

Could not load assembly 'System.Runtime.Loader' during startup registration


When you create new Xamarin.Forms project using .NET Standard, install Castle Windsor and run the project on Android it will fail with the following error

D/Mono    ( 5829): Assembly Loader probing location: 'System.Runtime.Loader'.
F/monodroid-assembly( 5829): Could not load assembly 'System.Runtime.Loader' during startup registration.
F/monodroid-assembly( 5829): This might be due to an invalid debug installation.
F/monodroid-assembly( 5829): A common cause is to 'adb install' the app directly instead of doing from the IDE.

When I opened properties of the Android project and changed linking to Sdk and User assemblies the application ran as expected. I thought the linking option can only introduce problems as some codes won't be included, yet it fixes it.

Also, one thing to note, the previous project I worked on uses Reference whereas the newly created project uses PackageReference for nuget packages.

UPDATE: The project suddenly stopped working, removing Castle Windsor and/or changing linking options had no effect.

I did try clearing solution, nuget cache and building/running the project on different devices.


Solution

  • Moving back to packages.config nuget management fixed the problem.