-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Using an MVC app with PublishTrimmed no longer works. The same app worked in .NET 7.
This appears to be caused by the JsonSerializerIsReflectionEnabledByDefault changes. See dotnet/runtime#84378.
FYI @eiriktsarpalis
Expected Behavior
The app should work.
Steps To Reproduce
dotnet new mvc
- Add
<PublishTrimmed>true</PublishTrimmed>
to the csproj dotnet run
Exceptions (if any)
Unhandled exception. System.InvalidOperationException: JsonSerializerOptions instance must specify a TypeInfoResolver setting before being marked as read-only.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerOptionsNoTypeInfoResolverSpecified()
at System.Text.Json.JsonSerializerOptions.MakeReadOnly()
at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter..ctor(JsonSerializerOptions jsonSerializerOptions)
at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.CreateFormatter(JsonOptions jsonOptions)
at Microsoft.AspNetCore.Mvc.MvcCoreMvcOptionsSetup.Configure(MvcOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.UnnamedOptionsManager`1.get_Value()
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.<>c.<AddMvcCoreServices>b__5_0(IServiceProvider s)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
.NET Version
8.0.100-preview.7.23360.2
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templates