Skip to content
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

Add support for Net 9 #404

Merged
merged 3 commits into from
Nov 18, 2024
Merged

Conversation

rizi
Copy link
Contributor

@rizi rizi commented Nov 14, 2024

This pull request updates lamar to .net 9 and all of its dependencies, this should fix #405.

As already mentioned via discord, there seems to be a timing problem in asp.net core 9 in combination with lamar.

These tests in MinimalApiTests.integration_tests are red, it can be fixed when adding this two lines of code, after the call of .UseLamar(....) and builder.Build() and before the call of app.Run();

var container = (IContainer)app.Services;
container.GetServices<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter>();

Note
This workaround also works in real world asp.net core 9 applications.

The error when running the tests or starting a real world asp.net core 9 application
Unable to resolve service for type 'System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter]' while attempting to activate 'Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl'.
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)

I also added a break point in Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl and the IEnumerable<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter> is always empty, so it's seems there is some kind of timing issue when using Lamar (therefore it's not a problem with a missing registration).

Input from @jeremydmiller
Somehow the IEnumerable<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter> is not even tried to be resolved by lamar (except when calling container.GetServices<Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter>(); before (maybe cached by aspnet.core)?)

Edit
Other dependencies are resolved by lamar
image
image
image

But of course that isn't a real solution, any help would highly be appreciated.

@jeremydmiller jeremydmiller merged commit a9fd707 into JasperFx:master Nov 18, 2024
1 check passed
@rizi rizi deleted the AddSupportForNet9 branch November 18, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Net 9
2 participants