question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SimpleWithWebApplicationBuilderTests.HelloWorld

See original GitHub issue

Error Message

System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'IServiceProvider'.

Stacktrace

   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException() in Microsoft.Extensions.DependencyInjection.dll:token 0x600011e+0xa
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) in Microsoft.Extensions.DependencyInjection.dll:token 0x6000067+0x8
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) in Microsoft.Extensions.DependencyInjection.dll:token 0x6000062+0x0
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) in Microsoft.Extensions.DependencyInjection.Abstractions.dll:token 0x6000094+0x34
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) in Microsoft.Extensions.DependencyInjection.Abstractions.dll:token 0x6000095+0xe
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.ConfigureHostBuilder(IHostBuilder hostBuilder) in /_/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 202
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer() in /_/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 172
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers) in /_/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs:line 462
   at Microsoft.AspNetCore.Mvc.FunctionalTests.SimpleWithWebApplicationBuilderTests..ctor(MvcTestFixture`1 fixture) in /_/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs:line 16

Build

https://dev.azure.com/dnceng/public/_build/results?buildId=1183988&view=ms.vss-test-web.build-test-results-tab&runId=35603264&resultId=118571&paneView=debug

@davidfowl I’m concerned this happened on the first official build with your changes to WebApplicationFactory https://github.com/dotnet/aspnetcore/pull/33462/.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davidfowlcommented, Jun 12, 2021

Oh snap! Very nice

0reactions
davidfowlcommented, Jun 12, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Supporting integration tests with WebApplicationFactory in ...
In this post I look at the changes that were made to WebApplicationFactory to support minimal hosting APIs with WebApplicationBuilder in .
Read more >
Code samples migrated to the new minimal hosting model ...
CreateBuilder initializes a new instance of the WebApplicationBuilder class with preconfigured defaults. For more information, see ASP.
Read more >
Exploring the code behind WebApplicationBuilder
In this post we're going to look at the code behind them, to see how they achieve a simpler API, while still having...
Read more >
Tutorial: Create a minimal API with ASP.NET Core
Learn how to build a minimal API with ASP.NET Core.
Read more >
Integration Testing ASP.NET Core 6 WebAPI Applications
Learn a simple way to create integration tests for ASP. ... On the default route, the API returns “Hello World”, and for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found