System.InvalidOperationException When Using IAsyncDisposable
See original GitHub issueIs 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:
- Created 4 years ago
- Comments:18 (10 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The latest
develop
NuGet packages should have this properly implemented now.Great, will be in the next release.