-
Notifications
You must be signed in to change notification settings - Fork 111
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
Does not work in .net 6 #182
Comments
can you share code? |
I will try to put together a sample project for you as soon as I can. In the meantime if you want to try it yourself, just do what I did to create a blank aspnet core web api project and uncheck the controllers option. I then just copied and pasted the program.cs from your minimal api sample over the one it created and ran it. |
Good attempt at fixing it, pretty sure I tried the exact same thing. You can resolve the error by adding: // ProblemDetails requires the registration of IActionResultExecutor<ObjectResult>
// this is done by invoking either AddMvcCore() or AddControllers()
builder.Services.AddControllers(); Calling either |
It appears that when solving #157, commit 1857120 registered A couple of solutions:
|
I would highly recommend the last option. The goal of minimal apis is to avoid adding all the bloat from mvc/controllers when we don't need it. You could always go the route of detecting whether |
Replacing |
Having the same problem Im refactoring a new project from mvc to minimalapi. Any ETAs? |
I was looking at your code as an inspiration to render a Fhir OperationOutcome instead of ProblemDetails when I ran into the same issue. I was able to fix it by subclassing This might solve the issue here as well. |
Same one .NET8 "web api" console app after update 6.5.0 to 6.5.1.. I had to add |
I spent a full day trying to implement this library into an existing .net 6 application with no luck. I kept running into this error #157 and then a host of subsequent errors related to dependencies of IActionResultExecutor that were not registered. Upgrading to your latest nuget package 6.5.1 did not help. It added the registration for ObjectResultExecutor but none of its dependencies such as OutputFormatterSelector and IHttpResponseStreamWriterFactory. The dependency chain needed for this to work in a simple minimal api application is not there due the coupling to mvc. I was able to prove this by creating a brand new .net6 project, unchecking the option for controllers, and pasting your program.cs file from your minimal api example right in and running it. It fails on the builder.Build() line with this error:
System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor
1[Microsoft.AspNetCore.Mvc.ObjectResult] Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor': Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.OutputFormatterSelector' while attempting to activate 'Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor'.) ---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor
1[Microsoft.AspNetCore.Mvc.ObjectResult] Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor': Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.OutputFormatterSelector' while attempting to activate 'Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor'.---> System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.OutputFormatterSelector' while attempting to activate 'Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor'.
trucated for brevity
I tried adding these dependencies myself, but get stuck when adding one for IHttpResponseStreamWriterFactory since the class used by mvc is private and sealed. At that point I gave up. I am hoping you have some simple fix for this since I like your library. But honestly I think you may need to think about splitting your library, one for older mvc and the other for .net6+ minimal api and remove all mvc dependencies from it. The way things are going with .net6/7 much of what you have in your library is becoming obsolete or no longer the recommended best practice. Hope this helps guys.
The text was updated successfully, but these errors were encountered: