Description
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.
- ID: 8fd55089-b683-2202-6641-c7b61a132f14
- Version Independent ID: cc5f00d0-fb50-1229-8fa2-e66b1f45b284
- Content: Dependency injection in .NET
- Content Source: docs/core/extensions/dependency-injection.md
- Product: dotnet-fundamentals
- GitHub Login: @IEvangelist
- Microsoft Alias: dapine