Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
2 years ago I spent quite some time (and David Fowler even corrected my code in https://github.com/LLT21/NativeAOT5) to make a tiny kestrel that worked with Native AOT and reflection disabled for reasons described in closed issue #31561.
I upgraded the tiny kestrel code today to make it in sync with the one I use in the TechEmpower benchmarks under framework https://github.com/LLT21/FrameworkBenchmarks/tree/master/frameworks/CSharp/appmpower:
- First I upgraded to .NET 7: this is the project that now is in the master of https://github.com/LLT21/NativeAOT5. If one compiles this native with reflection disabled - specified in project file - on Mac M1 or Linux, this works perfect and runs as such each week successfully in the TechEmpower benchmarks.
- Then I upgraded to .NET 8 and receive an Unhandled Exception: MT4302744992: Reflection_Disabled error on the line:
using var kestrelServer = new KestrelServer(Options.Create(kestrelServerOptions), socketTransportFactory, NullLoggerFactory.Instance);
-> some reflection code has been added here in .NET 8.
The output is:
Unhandled Exception: MT4302744992: Reflection_Disabled
at Internal.Reflection.RuntimeTypeInfo.get_Name() + 0x5d
at Microsoft.Extensions.Internal.TypeNameHelper.ProcessType(StringBuilder&, Type, TypeNameHelper.DisplayNameOptions&) + 0x9c
at Microsoft.Extensions.Internal.TypeNameHelper.GetTypeDisplayName(Type, Boolean, Boolean, Boolean, Char) + 0x36
at Microsoft.Extensions.Logging.Logger`1..ctor(ILoggerFactory) + 0x23
at Microsoft.Extensions.Logging.LoggerFactoryExtensions.CreateLogger[T](ILoggerFactory) + 0x2f
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer..ctor(IOptions`1, IConnectionListenerFactory, ILoggerFactory) + 0x76
at tinykestrel.Program.<Main>d__0.MoveNext() + 0x119
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x6a
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x53
at tinykestrel.Program.<Main>(String[]) + 0x26
at tinykestrel!<BaseAddress>+0x3424d0
Could you please have a look into this as it is crucial for us to keep this tiny bit working.
@davidfowl : do you have an idea for the cause of this ?
Expected Behavior
Would be nice to keep the behavior backward compatible
Steps To Reproduce
Compile https://github.com/LLT21/NativeAOT5 with .NET 7 and with .NET 8: with the former it is working, with the latter not.
Exceptions (if any)
No response
.NET Version
8.0.100-preview.7.23376.3
Anything else?
No response