-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
marshal-ilgen component must be included #7249
Labels
Area: App+Library Build
Issues when building Library projects or Application projects.
needs-triage
Issues that need to be assigned.
Comments
naricc
added
Area: App+Library Build
Issues when building Library projects or Application projects.
needs-triage
Issues that need to be assigned.
labels
Aug 10, 2022
jonathanpeppers
added a commit
that referenced
this issue
Aug 12, 2022
Context: dotnet/runtime#71203 Fixes: #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`.
This was referenced Aug 15, 2022
jonathanpeppers
pushed a commit
to jonathanpeppers/xamarin-android
that referenced
this issue
Aug 17, 2022
Fixes: dotnet#7249 Context: dotnet/runtime#71203 Context: dotnet/runtime#60639 Context: dotnet/runtime#61685 Context: dotnet#7276 Mono introduced a new `marshal-ilgen` component in dotnet/runtime@de32c446 which needs to be used when *non-blittable type* is required. `string` marshaling is a form of non-blittable marshaling, as is `Marshal.PtrToStructure()` (?!). Eventually the idea is that assemblies should migrate to use the [`DllImport Generator`][0] for non-blittable marshaling purposes, then [`[assembly:DisableRuntimeMarshallingAttribute]`][1] can be applied to the assembly, and -- if no assemblies in an Android app require non-blittable marshaling -- then the `marshal-ilgen` component can be omitted from the `.apk`, reducing app size. That's a fair number of `if`s; this won't be happening soon. In the meantime, we need to start including the `marshal-ilgen` component in all .NET 7 RC1+ builds so that our existing `[DllImport]` declarations continue to work. Failure to do so results in runtime errors: 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* ) Update `@(_MonoComponent)` to add `marshal-ilgen`. In order to facilitate future testing, allow the `marshal-ilgen` component to be *excluded* if the `$(_AndroidExcludeMarshalIlgenComponent)` property is True. [0]: https://github.com/dotnet/runtimelab/tree/feature/DllImportGenerator [1]: dotnet/runtime#60639
ghost
locked as resolved and limited conversation to collaborators
Sep 17, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Area: App+Library Build
Issues when building Library projects or Application projects.
needs-triage
Issues that need to be assigned.
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
N/A
Description
After this change to mono, marshal-ilgen has been moved to a component: dotnet/runtime#71203. This is a step in eventually allowing the component to be dropped when not needed. For now, it must be available to the runtime. So it needs to be added here before this change is consumed by xamarin-android: https://github.com/xamarin/xamarin-android/blob/73f10df63b00ee8a21d61183056a26922c83e89d/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets#L198-L200
Steps to Reproduce
N/A
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: