Xamarin Android 应用在发布模式下崩溃(找不到默认构造函数)



我这里有一个 Xamarin 应用程序,它在调试模式下运行没有任何问题,但在发布模式下它会立即崩溃,说我的一个页面的默认构造函数丢失。

Unhandled Exception:
System.MissingMethodException: Default constructor not found for type PraxisApp.MasterPage occurred

有没有人有任何建议,为什么在发布模式下会发生这种情况?

这很可能是由于它被单声道链接器剥离的事实:

  • https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker

将 PreserveAttribute 添加到 Page 类的顶部:

[Preserve (AllMembers = true)]
public class MasterPage
{
~~~
}

尝试将"PraxisApp.MasterPage;"添加到忽略程序集(ProjectSettings -> Android Build -> Linker(

相关内容

最新更新