.NET for Android 錯誤 XA1049

範例訊息

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

Issue

$(AndroidEnableMarshalMethods) 在修剪後重寫管理組件,且 $(PublishReadyToRun) 為這些組合語言加入原生程式碼。 Marshal 方法改寫器無法修改 ReadyToRun 組件。

解決方案

在專案檔案中停用 marshal 方法或 ReadyToRun:

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

Alternatively:

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