在启动注册期间无法加载程序集 'System.Runtime.Loader'

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

当您使用 .NET Standard 创建新的 Xamarin.Forms 项目时,在 Android 上安装 Castle Windsor 和 运行 项目将失败并出现以下错误

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.

当我打开 Android 项目的属性并按预期更改到 Sdk and User assemblies 应用程序 运行 的链接时。我认为链接选项只会引入问题,因为某些代码不会被包含在内,但它修复了它。

另外,需要注意一件事,我之前的项目使用 Reference 而新创建的项目使用 PackageReference 作为 nuget 包。

更新: 项目突然停止工作,删除 Castle Windsor and/or 更改链接选项无效。

我确实尝试在不同设备上清除解决方案、nuget 缓存和 building/running 项目。

回到 packages.config nuget 管理解决了这个问题。