Skip to content

BuildServiceProvider does not activate service #53177

@tomazv

Description

@tomazv

Type of issue

Code doesn't work

Description

The following example is wrong:

using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();

services.AddActivatedSingleton<MyService>();

ServiceProvider provider = services.BuildServiceProvider();

BuildServiceProvider() doesn't activate the service.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection/auto-activation?tabs=dotnet-cli

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/dependency-injection/auto-activation.md

Document Version Independent Id

5bbf9150-5b16-c5e3-7207-906fa7c0c132

Platform Id

5e9b375b-bdce-6e92-5158-77e0ccc96940

Article author

@gewarren

Metadata

  • ID: 079daeaa-bb2a-5574-e909-225118b018a5
  • PlatformId: 5e9b375b-bdce-6e92-5158-77e0ccc96940
  • Service: dotnet-fundamentals

Related Issues

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status

🔖 Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions