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

AspNetCore 2.2 AspNetCoreHostingModel InProcess not working #488

Closed
valeriob opened this issue May 21, 2019 · 7 comments
Closed

AspNetCore 2.2 AspNetCoreHostingModel InProcess not working #488

valeriob opened this issue May 21, 2019 · 7 comments

Comments

@valeriob
Copy link

Hi,
if you create a new AspNetCore 2.2 project and add LightInject.Microsoft.DependencyInjection package, configure the container in ConfigureServices

var container = new ServiceContainer(); return container.CreateServiceProvider(services);

when you run it blows with :

System.InvalidOperationException: 'No service for type 'Microsoft.AspNetCore.Hosting.Server.IServer' has been registered.'

@seesharper
Copy link
Owner

Could you create a simple repro of this and push it up on Github?

@valeriob
Copy link
Author

Suere,
there you go. /~https://github.com/onitgroup/LightInject_AspNetCore2_2InProcess
(Run it With IIS Express)

@seesharper
Copy link
Owner

Take at look at this PR

onitgroup/LightInject_AspNetCore2_2InProcess#1

@valeriob
Copy link
Author

Thanks, i was using it wrong :D

@valeriob
Copy link
Author

I would like to understand better, i'm looking at the code in
/~https://github.com/seesharper/LightInject.Microsoft.AspNetCore.Hosting/blob/88fc26fddcb42f2bde50ef3fc59be2c21191b279/src/LightInject.Microsoft.AspNetCore.Hosting/LightInjectWebHostBuilderExtensions.cs
i do not see anthing related to the issue, what's the difference in using this package instead of the approach i used ?

@seesharper
Copy link
Owner

It sets a couple of options that makes LightInject 100% compliant with the default container in Microsoft.Extensions.DependencyInjection.

/~https://github.com/seesharper/LightInject.Microsoft.DependencyInjection/blob/0b57968e2328f62bc262da9ce75d431954c82cfc/src/LightInject.Microsoft.DependencyInjection/LightInject.Microsoft.DependencyInjection.cs#L207

@valeriob
Copy link
Author

There you go:
options.DefaultServiceSelector = serviceNames => serviceNames.SingleOrDefault(string.IsNullOrWhiteSpace) ?? serviceNames.Last();

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants