Skip to content

Exception running Alba test host after upgrade to latest critter stack #74

Description

@esond

After upgrading to Wolverine V4 and Marten V8, the following exception is observed when running the Alba test host:

System.ObjectDisposedException
  HResult=0x80131622
  Message=Cannot access a disposed object.
Object name: 'IServiceProvider'.
  Source=Microsoft.Extensions.DependencyInjection
  StackTrace:
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.ConfigureHostBuilder(IHostBuilder hostBuilder)
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.get_Server()
   at Alba.AlbaWebApplicationFactory`1.Alba.IAlbaWebApplicationFactory.get_Server()
   at Alba.AlbaHost..ctor(IAlbaWebApplicationFactory factory, IAlbaExtension[] extensions)
   at Alba.AlbaHost.<For>d__34`1.MoveNext()
   at Bead.Management.Api.IntegrationTests.WebApplicationFixture.<InitializeAsync>d__5.MoveNext() in [REDACTED]\WebApplicationFixture.cs:line 52

  This exception was originally thrown at this call stack:
    [External Code]
    [REDACTED].WebApplicationFixture.InitializeAsync() in WebApplicationFixture.cs

After some troubleshooting, I can confirm that this only happens when the application is run using:

return await app.RunJasperFxCommands(args);

If we pass the null argument to the same command, the exception is no longer observed:

return await app.RunJasperFxCommands(args, null);

Outside of the Alba test host, the application works without issue for either invocation.

See Discord discussion for further info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions