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

use*_*232 1 android xamarin.android xamarin

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

Unhandled Exception:

System.MissingMethodException: Default constructor not found for type PraxisApp.MasterPage occurred
Run Code Online (Sandbox Code Playgroud)

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

Sus*_*ver 5

这很可能是因为它被 Mono Linker 剥离了:

在 Page 类的顶部添加一个 PreserveAttribute:

[Preserve (AllMembers = true)]
public class MasterPage
{
   ~~~
}
Run Code Online (Sandbox Code Playgroud)