Repository navigation
Description
Description
When publishing a .NET MAUI iOS app in Release (trimming enabled by default for iOS publish), ILLink crashes with an internal exception (IL1012)
The crash is a KeyNotFoundException for a compiler-generated async state machine type of a generic method:
Maui.Health.Services.HealthService/<GetHealthDataAsync>d__12\1`
The problem is in the Maui.Health dependency
Related to:
- [area-Tools-ILLink]: Key Not Found: 'QuickGraph.Collections.FibonacciHeap`2/<GetEnumerator>d__8' #109821
- Trimmer Error when publishing on IOS Kebechet/Maui.Health#7
- 🐛 fix trimming Kebechet/Maui.Health#8
Reproduction Steps
- Create a new .NET MAUI app targeting iOS (net10.0-ios).
- Add NuGet package:
Kebechet.Maui.Healthversion2.0.0(or any version that contains the same public generic async method shape).
- Reference the library in code (just calling the API is enough, example below).
- Publish in Release for iOS:
For some reason even local publish worked but it was still crashing in the pipeline
Expected behavior
Pipeline should succeed and the liner should crash on analysis of:
public async partial Task<List<TDto>> GetHealthData<TDto>(HealthTimeRange timeRange, CancellationToken cancellationToken)
and
public async partial Task<bool> WriteHealthData<TDto>(TDto data, CancellationToken cancellationToken) where TDto : HealthMetricBase
Actual behavior
The linker crashes with
/Users/runner/work/SatisFIT/SatisFIT/src/Client/SatisFIT.Client.App/MainPage.xaml(14,30): XamlC warning XC0025: Binding was not compiled because it has an explicitly set Source property and compilation of bindings with Source is not enabled. Consider enabling this optimization by setting the <MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation> in your project file and make sure the correct x:DataType is specified for this binding. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/Users/runner/work/SatisFIT/SatisFIT/src/Client/SatisFIT.Client.App/SatisFIT.Client.App.csproj::TargetFramework=net10.0-ios]
SatisFIT.Client.App -> /Users/runner/work/SatisFIT/SatisFIT/src/Client/SatisFIT.Client.App/bin/Release/net10.0-ios/ios-arm64/SatisFIT.Client.App.dll
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
Optimizing assemblies for size. This process might take a while.
ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://aka.ms/report-illink [/Users/runner/work/SatisFIT/SatisFIT/src/Client/SatisFIT.Client.App/SatisFIT.Client.App.csproj::TargetFramework=net10.0-ios]
Fatal error in IL Linker
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Maui.Health.Services.HealthService/<WriteHealthData>d__17`1' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Mono.Linker.Dataflow.CompilerGeneratedState.<GetCompilerGeneratedStateForType>g__MapGeneratedTypeTypeParameters|11_2(TypeDefinition generatedType, Dictionary`2 generatedTypeToTypeArgs, LinkContext context)
at Mono.Linker.Dataflow.CompilerGeneratedState.<GetCompilerGeneratedStateForType>g__MapGeneratedTypeTypeParameters|11_2(TypeDefinition generatedType, Dictionary`2 generatedTypeToTypeArgs, LinkContext context)
at Mono.Linker.Dataflow.CompilerGeneratedState.GetCompilerGeneratedStateForType(TypeDefinition type)
at Mono.Linker.Dataflow.CompilerGeneratedState.GetGeneratedTypeAttributes(TypeDefinition generatedType)
at ILLink.Shared.TrimAnalysis.FlowAnnotations.GetGeneratedTypeAttributes(TypeDefinition typeDef)
at ILLink.Shared.TrimAnalysis.FlowAnnotations.BuildTypeAnnotations(TypeDefinition type)
at ILLink.Shared.TrimAnalysis.FlowAnnotations.GetAnnotations(TypeDefinition type)
at ILLink.Shared.TrimAnalysis.FlowAnnotations.GetTypeAnnotation(TypeDefinition type)
at Mono.Linker.Dataflow.DynamicallyAccessedMembersTypeHierarchy.ProcessMarkedTypeForDynamicallyAccessedMembersHierarchy(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkTypeVisibleToReflection(TypeReference type, DependencyInfo& reason, MessageOrigin& origin)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason, MessageOrigin& origin)
at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference, DependencyInfo reason, MessageOrigin& origin)
at Mono.Linker.Steps.MarkStep.MarkFieldVisibleToReflection(FieldReference field, DependencyInfo& reason, MessageOrigin& origin)
at Mono.Linker.Steps.MarkStep.MarkFieldsVisibleToReflection(TypeDefinition type, DependencyInfo& reason, MessageOrigin origin, Boolean markBackingFieldsOnlyIfPropertyMarked)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.ProcessMarkedPending()
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
Error: /Users/runner/.nuget/packages/microsoft.net.illink.tasks/10.0.1/build/Microsoft.NET.ILLink.targets(103,5): error NETSDK1144: Optimizing assemblies for size failed. [/Users/runner/work/SatisFIT/SatisFIT/src/Client/SatisFIT.Client.App/SatisFIT.Client.App.csproj::TargetFramework=net10.0-ios]
Error: Process completed with exit code 1.
Regression?
dunno
Known Workarounds
fixed the ILLinker crash by removing the async state machine on the public generic method.
Kebechet/Maui.Health#8
Concrete fix commits:
- for
GetHealthData: Kebechet/Maui.Health@469a1da - for
WriteHealthData: Kebechet/Maui.Health@d00d2fc
Configuration
Current runner version: '2.330.0'
Runner Image Provisioner
Hosted Compute Agent
Version: 20251211.462
Commit: 6cbad8c2bb55d58165063d031ccabf57e2d2db61
Build Date: 2025-12-11T16:28:49Z
Worker ID: {99019fec-2f3d-4407-9b62-e7fa8973ab04}
Operating System
macOS
26.0.1
25A362
Runner Image
Image: macos-26-arm64
Version: 20251216.0100.1
Included Software: https://github.com/actions/runner-images/blob/macos-26-arm64/20251216.0100/images/macos/macos-26-arm64-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-26-arm64%2F20251216.0100
DOTNET_SDK_VERSION: "10.0.101"
WORKLOAD_SET_VERSION: "10.0.101.1" # https://github.com/dotnet/macios/releases
TARGET_FRAMEWORK: net10.0-ios
XCODE_VERSION: "26.2"
BUILD_CONFIGURATION: Release
dotnet publish command
dotnet publish src/Client/SatisFIT.Client.App/SatisFIT.Client.App.csproj -c Release -f net10.0-ios -o ~/artifacts --no-restore --p:NoDSymUtil=false --p:ApplicationDisplayVersion="20.5.3" --p:ApplicationVersion="587" --p:RuntimeIdentifier=ios-arm64 --p:ArchiveOnBuild=True --p:CodesignKey="Apple Distribution: John Doe (AAAAAAA)" --p:CodesignProvision="SatisFIT-profile"
Other information
No response
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
dotnet-policy-service commentedon Dec 31, 2025
Tagging subscribers to this area: @dotnet/illink
See info in area-owners.md if you want to be subscribed.
Kebechet commentedon Feb 21, 2026
@agocke seems like copilot failed to implement the fix for this?
#123094
#123095
sbomer commentedon Jun 25, 2026
Fixed by dotnet/roslyn#83790, and #126733 is adding a regression test.
[ILLink] Add regression test for KeyNotFoundException crash in async …