You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the message will go through a series of retries and will eventually be moved to the error queue with a similar exception message:
2022-12-23 11:04:23.388 ERROR Moving message '1243a077-6606-4fc7-ae43-af7400a56572' to the error queue 'error' because processing failed due to an exception:
System.InvalidOperationException: 'AsyncDisposable' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
at NServiceBus.MainPipelineExecutor.Invoke(MessageContext messageContext, CancellationToken cancellationToken) in /_/src/NServiceBus.Core/Pipeline/MainPipelineExecutor.cs:line 63
at NServiceBus.LearningTransportMessagePump.ProcessFile(ILearningTransportTransaction transaction, String messageId, CancellationToken messageProcessingCancellationToken) in /_/src/NServiceBus.Core/Transports/Learning/LearningTransportMessagePump.cs:line 340
For Single instance implementations, the InvalidOperationException will be raised when attempting to stop the endpoint:
2023-01-12 17:10:23.046 INFO Initiating shutdown.
Unhandled exception. System.InvalidOperationException: 'SingletonAsyncDisposable' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
at Microsoft.Extensions.DependencyInjection.ServiceProvider.Dispose()
at NServiceBus.HostingComponent.Stop() in /_/src/NServiceBus.Core/Hosting/HostingComponent.cs:line 100
at NServiceBus.RunningEndpointInstance.Stop(CancellationToken cancellationToken) in /_/src/NServiceBus.Core/Unicast/RunningEndpointInstance.cs:line 66
at Program.Main() in /home/danielmarbach/Projects/docs.particular.net/samples/fullduplex/Core_8/Server/Program.cs:line 29
at Program.<Main>()
Symptoms
When registering Instance per unit of work implementations of
IAsyncDisposable
and resolving them as part of a message handlerthe message will go through a series of retries and will eventually be moved to the error queue with a similar exception message:
For Single instance implementations, the
InvalidOperationException
will be raised when attempting to stop the endpoint:Who's affected
You are affected if:
IAsyncDisposable
is registered byendpointConfiguration.RegisterComponents(…)
as either:services => services.AddSingleton<SingletonAsyncDisposable>()
services => services.AddScoped<ScopedAsyncDisposable>()
Root cause
The internally managed container is not disposed using the
IAsyncDisposable
interface.Backported to
The text was updated successfully, but these errors were encountered: