Skip to content

Do not call 'IServiceCollection.BuildServiceProvider' in 'ConfigureServices' #187

Open

Description

@andersjarl

Hi!

When doing call in ConfigureServices:

services.AddExtCore(this.extensionsPath, false, new ExtCore.WebApplication.DefaultAssemblyProvider(services.BuildServiceProvider())

You will get the following warning:
warning ASP0000: Calling 'BuildServiceProvider' from application code results in an additional copy of singleton services being created. Consider alternatives such as dependency injecting services as parameters to 'Configure'.

Is this something you are going to address?
It is not recommended to use BuildServiceProvider inside ConfigureServices but the constructor of DefaultAssemblyProvider expects to get a ServiceProvider.

Regards
Anders

Activity

  1. DmitrySikorsky commented on Mar 5, 2021

    @DmitrySikorsky
    Member

    Hi, thank you, I will review this part of code.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions