-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web API broken in .NET 7.0 after trimming #44997
Comments
Trimming isn't really supported for ASP.NET Core apps, it's best effort (if it works it works) until .NET 8. If you're looking for a workaround, it might be possible to help here. If you remove |
Oh, this is a surprising info, because I use trimming successfully in several projects ASP.NET core projects with both .NET 6 and .NET 5. |
But you got warnings and ignored them right? cc @sbomer about the trimmer changes in 7.0 |
Yes. Fyi: Removing the above setting works in the minimal example above but unfortunately not in the production projects because they are trimmed to much afterwards. |
@MarkusRodler see this issue: dotnet/linker#3039. As a workaround, you might be able to use |
@sbomer Yes that works like before. Thanks. |
Is there an existing issue for this?
Describe the bug
After upgrading multiple working projects from .NET 6.0 to .NET 7.0, all .NET Web Apis are broken that I tried.
I am using trimming and r2r.
Expected Behavior
No response
Steps To Reproduce
dotnet new webapi --use-minimal-apis -n Net7trimmingbug --no-https --no-openapi
Program.cs
:Exceptions (if any)
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMM30E2TLGA4", Request id "0HMM30E2TLGA4:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: Encountered a parameter of type 'System.String' without a name. Parameters must have a name.
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArgument(ParameterInfo parameter, RequestDelegateFactoryContext factoryContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArguments(ParameterInfo[] parameters, RequestDelegateFactoryContext factoryContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArgumentsAndInferMetadata(MethodInfo methodInfo, RequestDelegateFactoryContext factoryContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.InferMetadata(MethodInfo methodInfo, RequestDelegateFactoryOptions options)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList
1 groupConventions, IReadOnlyList
1 groupFinallyConventions)at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.CreateEndpointsUnsynchronized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.EnsureEndpointsInitialized()
at Microsoft.AspNetCore.Routing.CompositeEndpointDataSource.get_Endpoints()
at Microsoft.AspNetCore.Routing.DataSourceDependentCache
1.Initialize() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func
1 valueFactory)at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func
1 matcherBuilderFactory) at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|8_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task
1 matcherTask)at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
.NET Version
7.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: