You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BadImageFormatException when loading a type with a generic constraint on an interface over a multi-dimensional array #137934
Since .NET 10, the runtime fails to load a type that declares a generic method (or is itself generic) with a constraint on a generic interface whose type argument is a multi-dimensional array, e.g. where T : IFoo<int[,]>. Any use of the type throws System.BadImageFormatException: Bad binary signature. (0x80131192), even calling an unrelated member, so the whole type is unusable.
The same binary runs fine on .NET 9 and on .NET 10.0.0-rc.2, so this is a runtime regression between 10.0.0-rc.2 and 10.0.2, not a compiler issue.
Unhandled exception. System.BadImageFormatException: Bad binary signature. (0x80131192) at Program.Main()
10.0.14
same exception
11.0.0
same exception
A net10.0 build behaves the same. The exception is thrown while Main is being compiled, so a try/catch around the call in Main does not catch it.
Variations, each in its own type:
Constraint
.NET 8 / 9
.NET 10.0.14 / 11.0.0
where T : IFoo<int[,]> on a method
works
throws
where T : IFoo<int[,]> on the type (class C<T> where T : IFoo<int[,]>)
works
throws
where T : IEnumerable<int[,]> (BCL interface)
works
throws
where T : Bar<int[,]> (class constraint)
works
works
where T : IFoo<int[]> (single-dimensional array)
works
works
Regression?
Yes. Works on .NET 9.0.18 and .NET 10.0.0-rc.2.25502.107, fails on .NET 10.0.2 and later (10.0.14 and 11.0.0 tested). 10.0.0 and 10.0.1 were not available to test.
Known Workarounds
None found at the source level. Moving the constrained member into a separate type keeps the rest of the original type usable.
Found through the Mockolate source generator (Testably/Mockolate#1043): generated mock helpers contain Initialize<T>() where T : <mocked interface>, so mocks of generic interfaces closed over a multi-dimensional array (e.g. IRepository<int[,]>) fail to load on .NET 10+.
Activity
MihuBot commentedon Nov 19, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):