Skip to content

Why "Scope Validation" is being done only at "Development" environment #29147

Closed
@fkucuk

Description

@fkucuk

Great article. But I wonder why the "Scope Validation" is being done at "Development" environment?

We've just noticed that a Net6 application throwing exeption (Cannot consume scoped service 'My Interface registered as Scoped' from singleton 'Microsoft.Extensions.Hosting.IHostedService'.) on my computer while building perfectly on my collegue's machine. And we realized that my friend has no Development environment variable which caused the application to run in production mode.

https://docs.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#scope-validation

I mean why .Net is validating the scope only in development environment? Isn't that confusing?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Labels

dotnet-fundamentals/svcneeds-more-infoNeeds more info from OP. Auto-closed after 2 weeks if no response. [org][resolution]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions