Skip to content

XALNS7015: Writing mixed-mode assemblies is not supported when FixAbstractMethodsStep patches an R2R-compiled Java binding assembly (CoreCLR, .NET 11) #11025

Closed

Description

@simonrozsival

Description

Building a .NET Android / MAUI Android app with CoreCLR (the default runtime in .NET 11) in Release configuration fails with:

error XALNS7015: System.NotSupportedException: Writing mixed-mode assemblies is not supported
   at Mono.Cecil.ModuleWriter.Write(...)
   at Mono.Cecil.AssemblyDefinition.Write(...)
   at Xamarin.Android.Tasks.SaveChangedAssemblyStep.ProcessAssembly(...)
   at Xamarin.Android.Tasks.AssemblyModifierPipeline.RunPipeline(...)
   at Xamarin.Android.Tasks.AssemblyModifierPipeline.RunTask()
   at Microsoft.Android.Build.Tasks.AndroidTask.Execute()

This failure is already documented in the test suite but suppressed:

// BuildTest.cs - SimilarAndroidXAssemblyNames
Assert.Ignore("CoreCLR: fails because of a Mono.Cecil lack of support");

CoreCLR is the default Android runtime starting in .NET 11, so this is now a first-class failure for Release builds.

Steps to Reproduce

  1. Create a .NET MAUI Android app targeting net11.0-android
  2. Reference a NuGet package containing a Java binding assembly that has a concrete Java.Lang.Object subclass missing an abstract interface method implementation — for example:
    <PackageReference Include="Microsoft.Intune.Maui.Essentials.android" Version="11.5.1" />
  3. Build Release for android-arm64:
    dotnet build -c Release -r android-arm64
    

Expected Behavior

Build succeeds.

Actual Behavior

Build fails with XALNS7015.

Root Cause

The pipeline in _LinkAssembliesNoShrink has two steps relevant here:

1. FixAbstractMethodsStep — inspects each Java.Lang.Object subclass in binding assemblies and injects stub methods (throwing AbstractMethodError) for any abstract interface methods that are not yet implemented. It sets context.IsAssemblyModified = true when it does so.

2. SaveChangedAssemblyStep — if IsAssemblyModified, calls assembly.Write(destination, writerParameters) via Mono.Cecil.

With MonoVM, the SourceFiles passed to _LinkAssembliesNoShrink are plain IL assemblies. With CoreCLR (new in .NET 11), _LinkAssembliesNoShrinkInputs feeds R2R-compiled assemblies from obj/…/R2R/ as SourceFiles. When FixAbstractMethodsStep needs to patch such an assembly, SaveChangedAssemblyStep fails because Mono.Cecil cannot write R2R assemblies (the ILONLY PE flag is cleared; the file contains embedded native ARM64 code).

Most binding assemblies (e.g. MSAL) already have all abstract methods implemented and pass through unmodified (IsAssemblyModified = false), hitting the safe CopyIfChanged path. The failure only surfaces for assemblies where FixAbstractMethods actually finds and injects a stub — in this case, IMAMServiceAuthenticationCallbackExtendedInvoker in MAMSDKBinding.dll was missing its AcquireToken implementation.

Environment

  • .NET SDK: 11.0.100-preview.2.26159.112
  • Microsoft.Android.Sdk.Darwin: 36.1.99-preview.2.154
  • Reproducer NuGet: Microsoft.Intune.Maui.Essentials.android 11.5.1
  • Configuration: Release, android-arm64, CoreCLR
  • macOS

Activity

  1. added
    needs-triage
    on Mar 26, 2026
  2. added
    Area: CoreCLR
    copilot
    and removed
    needs-triage
    on Mar 26, 2026
  3. added this to the .NET 11 milestone on Mar 26, 2026
  4. added 3 commits that reference this issue on Mar 26, 2026
    dabe1ad
    5e65839
    ebcf2bd
  5. michaldobrodenka commented on Apr 23, 2026

    @michaldobrodenka

    I have this problem with net10-android36 when <UseMonoRuntime>false</UseMonoRuntime>

  6. jonathanpeppers commented on Aug 12, 2026

    @jonathanpeppers
    Member

    Current status as of August 12, 2026: this is not fixed in main or in a released build.

    • The proposed fix in Fix XALNS7015: run FixAbstractMethodsStep before R2R in non-trimmed CoreCLR builds #11027 was closed as stale on May 14, 2026 and was never merged.
    • The follow-up fix/11025-r2r-abstract-methods-v2 branch also remains unmerged and has no active PR.
    • Current main still runs _LinkAssembliesNoShrink using @(ResolvedAssemblies) without ordering it before _PrepareForReadyToRunCompilation.
    • The affected CoreCLR cases in SimilarAndroidXAssemblyNames and AndroidAddKeepAlives are still skipped with Assert.Ignore ("CoreCLR: fails because of a Mono.Cecil lack of support").

    Since CoreCLR has already shipped and is now the default runtime, this is a shipped-product issue for non-trimmed Release/CoreCLR builds whenever a binding assembly requires FixAbstractMethodsStep rewriting. The trigger is narrow, but affected packages fail reliably with XALNS7015. We should revive/rebase the fix, restore the skipped tests, and consider servicing the affected shipped versions.

  7. added a commit that references this issue on Aug 24, 2026
    2ee69d9
  8. locked and limited conversation to collaborators on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: CoreCLRcopilot

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions