适用于 Android 的 .NET 错误 XA1049

示例消息

error XA1049: The 'AndroidEnableMarshalMethods' and 'PublishReadyToRun' MSBuild properties cannot both be set to 'true'. Set one property to 'false'.

Issue

$(AndroidEnableMarshalMethods) 在裁剪后重写托管程序集,而 $(PublishReadyToRun) 向这些程序集添加本机代码。 封送方法重写器无法修改 ReadyToRun 程序集。

解决方案

在项目文件中禁用封送处理方法或 ReadyToRun:

<PropertyGroup>
  <AndroidEnableMarshalMethods>false</AndroidEnableMarshalMethods>
</PropertyGroup>

Alternatively:

<PropertyGroup>
  <PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>