From 303f41f16abebd390654b1d571982c0831777e27 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 12 Aug 2022 14:02:02 -0500 Subject: [PATCH] Include `marshal-ilgen` Mono component by default Context: https://github.com/dotnet/runtime/pull/71203 Fixes: https://github.com/xamarin/xamarin-android/issues/7249 Apps on this PR currently crash with: mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in (wrapper managed-to-native) object:wrapper_native_0x7725af156f10 (intptr): IL_0012: calli 0x00000003 mono-rt : at System.Runtime.InteropServices.Marshal.PtrToStructureHelper(IntPtr , Object , Boolean ) mono-rt : at System.Runtime.InteropServices.Marshal.PtrToStructure(IntPtr , Type ) mono-rt : at Java.Interop.JniRuntime.CreateInvoker(IntPtr ) mono-rt : at Java.Interop.JniRuntime..ctor(CreationOptions ) mono-rt : at Android.Runtime.AndroidRuntime..ctor(IntPtr , IntPtr , Boolean , IntPtr , IntPtr , Boolean ) mono-rt : at Android.Runtime.JNIEnv.Initialize(JnienvInitializeArgs* ) Which, I assume is due to a missing Mono component. We should add the component by default: <_MonoComponent Condition=" '$(_IncludeMarshalIlGen)' != 'false' " Include="marshal-ilgen" /> In the future, someone could experiment by setting `$(_IncludeMarshalIlGen)` to `false`. --- .../targets/Microsoft.Android.Sdk.AssemblyResolution.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets index 6318cd5f48f..4b2432f7419 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets @@ -198,6 +198,7 @@ _ResolveAssemblies MSBuild target. <_MonoComponent Condition=" '$(AndroidEnableProfiler)' == 'true' " Include="diagnostics_tracing" /> <_MonoComponent Condition=" '$(AndroidUseInterpreter)' == 'true' " Include="hot_reload" /> <_MonoComponent Condition=" '$(AndroidIncludeDebugSymbols)' == 'true' " Include="debugger" /> + <_MonoComponent Condition=" '$(_IncludeMarshalIlGen)' != 'false' " Include="marshal-ilgen" />