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

Weird service collection self-registration #2795

Closed
j-mok opened this issue May 16, 2024 · 3 comments
Closed

Weird service collection self-registration #2795

j-mok opened this issue May 16, 2024 · 3 comments
Assignees

Comments

@j-mok
Copy link
Contributor

j-mok commented May 16, 2024

Hi, is there any reason the platform registers the DI service collection in itself? This feels very weird...

@mvktsk
Copy link
Contributor

mvktsk commented May 16, 2024

Task https://virtocommerce.atlassian.net/browse/VP-8582 has been created

@OlegoO
Copy link
Contributor

OlegoO commented May 22, 2024

@j-mok Good quetion, the code was added 5 years ago, I will review with the team and maybe find some reason.

@OlegoO OlegoO self-assigned this May 22, 2024
@OlegoO
Copy link
Contributor

OlegoO commented May 22, 2024

This code is required to resolve IServiceCollection for ModuleInitializer class and then pass to modules. Without this line, DI throws exception. Maybe code can be improved but let's keep it as is.

Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.DependencyInjection.IServiceCollection' while attempting to activate 'VirtoCommerce.Platform.Modules.ModuleInitializer'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
...   
at VirtoCommerce.Platform.Modules.ServiceCollectionExtensions.AddModules(IServiceCollection services, IMvcBuilder mvcBuilder, Action`1 setupAction) in C:\Projects\git\VirtoCommerce\vc-platform\src\VirtoCommerce.Platform.Web\Extensions\ServiceCollectionExtensions.cs:line 33
...

@OlegoO OlegoO closed this as completed May 22, 2024
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

No branches or pull requests

3 participants