Repository navigation
Closed
Labels
Description
Describe the bug
Since .NET 11 RC2, dotnet publish -p:PublishReadyToRun=true fails when the assembly contains an anonymous type with two or more non-ASCII property names of the same length (e.g. Japanese identifiers).
The same code publishes fine with .NET 10, and also with .NET 11 RC2 when the property names are ASCII.
Steps to reproduce
// Program.cs
var ok = new { x = "", y = "" }; // publishes fine
var ng = new { あ = "", い = "" }; // crossgen2 crashes
Console.WriteLine(ok.Equals(ng));<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net11.0</TargetFramework>
</PropertyGroup>
</Project>dotnet publish -c Release -p:PublishReadyToRun=true
Expected behavior
Publish succeeds, as it does with .NET 10 or with ASCII property names.
Actual behavior
C:\Program Files\dotnet\sdk\11.0.100-rc.2.26504.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(501,5): error Error: An item with the same key has already been added. Key: DelayLoadHelperImport(DelayLoad_Helper) -> SignaturePointer_GenericLookupSignature(CORINFO_LOOKUP_THISOBJ / TypeHandle: S_P_CoreLib_System_Collections_Generic_EqualityComparer_1<___j__TPar_System___Canon> (R2RCJKBug___f__AnonymousType1_2<System___Canon__System___Canon>__Equals)
at System.Collections.Generic.Dictionary`2.TryInsert(TKey, TValue, InsertionBehavior) in /_/src/runtime/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs:line 549
at ILCompiler.ObjectWriter.ObjectWriter.EmitObject(Stream, IReadOnlyCollection`1, IObjectDumper, Logger) in /_/src/runtime/src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs:line 438
at ILCompiler.DependencyAnalysis.ReadyToRunObjectWriter.EmitReadyToRunObjects(ReadyToRunContainerFormat, Logger) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/CodeGen/ReadyToRunObjectWriter.cs:line 197
at ILCompiler.ReadyToRunCodegenCompilation.Compile(String) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs:line 434
at ILCompiler.Program.RunSingleCompilation(Dictionary`2, InstructionSetSupport, String, Dictionary`2, HashSet`1, ReadyToRunCompilerContext, Logger) in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 705
at ILCompiler.Program.Run() in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 321
at ILCompiler.Crossgen2RootCommand.<>c__DisplayClass216_0.<.ctor>b__0(ParseResult) in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs:line 275
at ...
C:\Program Files\dotnet\sdk\11.0.100-rc.2.26504.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(501,5): error System.ArgumentException: An item with the same key has already been added. Key: DelayLoadHelperImport(DelayLoad_Helper) -> SignaturePointer_GenericLookupSignature(CORINFO_LOOKUP_THISOBJ / TypeHandle: S_P_CoreLib_System_Collections_Generic_EqualityComparer_1<___j__TPar_System___Canon> (R2RCJKBug___f__AnonymousType1_2<System___Canon__System___Canon>__Equals)
at System.Collections.Generic.Dictionary`2.TryInsert(TKey, TValue, InsertionBehavior) in /_/src/runtime/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs:line 549
at ILCompiler.ObjectWriter.ObjectWriter.EmitObject(Stream, IReadOnlyCollection`1, IObjectDumper, Logger) in /_/src/runtime/src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs:line 438
at ILCompiler.DependencyAnalysis.ReadyToRunObjectWriter.EmitReadyToRunObjects(ReadyToRunContainerFormat, Logger) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/CodeGen/ReadyToRunObjectWriter.cs:line 197
at ILCompiler.ReadyToRunCodegenCompilation.Compile(String) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs:line 434
at ILCompiler.Program.RunSingleCompilation(Dictionary`2, InstructionSetSupport, String, Dictionary`2, HashSet`1, ReadyToRunCompilerContext, Logger) in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 705
at ILCompiler.Program.Run() in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 321
at ILCompiler.Crossgen2RootCommand.<>c__DisplayClass216_0.<.ctor>b__0(ParseResult) in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs:line 275
at ...
C:\Program Files\dotnet\sdk\11.0.100-rc.2.26504.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(376,5): error NETSDK1096: アセンブリのパフォーマンスの最適化が失敗しました。失敗したアセンブリを最適化の対象から除外するか、PublishReadyToRun プロパティを false に設定してください。
Is this a regression?
Yes. Works with .NET 10 SDK; fails with 11.0.100-rc.2.26504.105.
Are there any workarounds?
- Rename the anonymous type properties so that their sanitized names don't collide (e.g. use ASCII names), or replace the anonymous type with a named type (
record). - Exclude the assembly via
PublishReadyToRunExclude, or setPublishReadyToRun=false.
dotnet --info output
Host:
Version: 11.0.0-rc.2.26504.105
Architecture: x64
Commit: 820230c386
.NET SDKs installed:
10.0.402 [C:\Program Files\dotnet\sdk]
11.0.100-rc.2.26504.105 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 11.0.0-rc.2.26504.105 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 11.0.0-rc.2.26504.105 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 11.0.0-rc.2.26504.105 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not foundIDE version
JetBrains Rider 2026.2.3.1
Other details
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
github-actions commentedon Oct 14, 2026
🎯 Agentic Issue Triage
Triage Assessment:
@jtschuster|@dotnet/illinkmedium- Crash occurs inside crossgen2 (runtime-owned), so the SDK may not be the root-cause component.➡️ Summary: PublishReadyToRun fails in .NET 11 RC2 with a duplicate-key crossgen2 exception for anonymous types with same-length non-ASCII property names. Consider routing to dotnet/runtime crossgen2 if confirmed.
jtschuster commentedon Oct 14, 2026
Same root cause as #133229 - non-ascii code mangles to
_.florianwakam commentedon Nov 16, 2026
We hit this crash with the official .NET 11 release (SDK 11.0.100), not only with RC2. It happens on an obfuscated third-party library when publishing with
-p:PublishReadyToRun=true -p:PublishReadyToRunComposite=truefor linux-x64:The same project publishes fine with .NET 10. The library likely has non-ASCII identifiers of the same length, which matches #133229. Our workaround is to exclude it from ReadyToRun (
PublishReadyToRunExcludeandPublishReadyToRunCompositeExclusions).This now breaks ReadyToRun publishing for anyone who uses an obfuscated dependency on the official .NET 11 release. Could #133230 be considered for an 11.0.x servicing release?
Fix ReadyToRun generic parameter symbol collisions (dotnet#136191)