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.

System.InvalidOperationException When Using IAsyncDisposable

See original GitHub issue

Is this a bug report?

Yes

Can you also reproduce the problem with the latest version?

Yes

Occurs When

When using MassTransit DI with a scoped consumer which has a dependency which only implements IAsyncDisposable.

It appears MassTransit should be calling DisposeAsync()

Stacktrace

MassTransit.ReceiveTransport: Error: R-FAULT rabbitmq://mq/report_queue 000a0000-ac16-0242-5f5f-08d794932d75 <redacted>.IMyCommand <redacted>.MyConsumer(00:00:06.8635823)

System.InvalidOperationException: '<redacted type name>' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
   at MassTransit.Scoping.ConsumerContexts.CreatedConsumerScopeContext`3.Dispose()
   at MassTransit.Scoping.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next)
   at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)

Environment

Dotnet version: .NET Core 3.0.0 Package: MassTransit (6.0.1) Package: MassTransit.Extensions.DependencyInjection (6.0.1)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
phatboygcommented, Jul 14, 2021

The latest develop NuGet packages should have this properly implemented now.

0reactions
phatboygcommented, Jul 14, 2021

Great, will be in the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to dispose a service implementing IAsyncDisposable ...
InvalidOperationException : 'AddressService.Web.Jobs.Test' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
Read more >
Implement a DisposeAsync method
If no synchronous disposable of your class is possible, having only IAsyncDisposable is acceptable. All of the guidance for implementing the ...
Read more >
How to work with IAsyncDisposable in .NET 6
Implement synchronous and asynchronous dispose in .NET ... The System.IAsyncDisposable interface was released with C# 8.0. Similar to IDisposable, ...
Read more >
New dependency injection features in .NET 6
System.InvalidOperationException: 'Foo' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container. at Microsoft.
Read more >
NServiceBus 8.0.3 – Patch release available
System.InvalidOperationException: 'SingletonAsyncDisposable' type only implements IAsyncDisposable. Use DisposeAsync to dispose 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