question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not work in .net 6

See original GitHub issue

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<ObjectResult> 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.IActionResultExecutor1[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.IActionResultExecutor1[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.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
khellangcommented, Aug 31, 2022

Replacing ObjectResultExecutor with MinimalApiResultExecutor will just bring back the problem I initially tried to solve (#180). I have an idea on how to fix this, but I need to do some experimentation. In the meantime, you can just revert back to v6.5.0, which uses the MinimalApiResultExecutor.

1reaction
zyofengcommented, Oct 3, 2022

Replacing ObjectResultExecutor with MinimalApiResultExecutor will just bring back the problem I initially tried to solve (#180). I have an idea on how to fix this, but I need to do some experimentation. In the meantime, you can just revert back to v6.5.0, which uses the MinimalApiResultExecutor.

Having the same problem Im refactoring a new project from mvc to minimalapi. Any ETAs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET Framework technologies unavailable on .NET 6+
Several technologies available to .NET Framework libraries aren't available for use with .NET 6+, such as app domains, remoting, and code ...
Read more >
Breaking changes in .NET 6
NET 6, the breaking changes listed here might affect you. Changes are grouped by technology area, such as ASP.NET Core or Windows Forms....
Read more >
New version .NET 6 is not work without get set
My old project is using .NET Core 2.2 and I need to migrate it to .NET 6. The previous developer added some classes...
Read more >
NET 6.0 Known Issues
NET 6.0 Known Issues. You may encounter the following known issues, which may include workarounds, mitigations or expected resolution timeframes.
Read more >
[Bug] Does not work with .NET 6 · Issue #232
Environment: .NET 6, Razor Pages, linux. Does not work. Here is a MINIMAL repro: dotnet new webapp (razor pages); dotnet add package ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found