Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/core/extensions/dependency-injection/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ If a class has many injected dependencies, it might be a sign that the class has

### Disposal of services

The container is responsible for cleanup of types it creates, and calls <xref:System.IDisposable.Dispose%2A> on <xref:System.IDisposable> instances. Services resolved from the container should never be disposed by the developer. If a type or factory is registered as a singleton, the container disposes the singleton automatically.
The container is responsible for cleanup of types it creates, and calls <xref:System.IDisposable.Dispose%2A> on <xref:System.IDisposable> instances. Services resolved from the container should never be disposed by the developer. The container disposes services automatically based on their lifetime:

- **Transient** and **scoped** services are disposed at the end of the scope in which they were resolved. In apps that process requests, this is typically at the end of the request.
- **Singleton** services are disposed when the service container is disposed, usually at application shutdown.

In the following example, the services are created by the service container and disposed automatically:

Expand Down