Scope throws an exception
// Get a host builder | |
var hostBuilder = CreateHostBuilder(args); | |
// Add our service as scoped. | |
hostBuilder.ConfigureServices(srv => | |
{ | |
srv.AddScoped<MyAsyncOnlyDisposableObject>(); | |
}); | |
// Get our container | |
var host = hostBuilder.Build(); | |
using(var serviceScope = host.Services.CreateScope()) | |
{ | |
var myObject = serviceScope.ServiceProvider.GetRequiredService<MyAsyncOnlyDisposableObject>(); | |
} // Exception thrown here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment