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
An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An item with the same key has already been added.
Source Error:
{
var castContext = context as IRequest;
return await this.mediator.Send(castContext, token);
}
This is what our registry looks with structure map
public RegisterMediatr()
{
this.Scan(scanner =>
{
scanner.AssemblyContainingType(typeof(IRequestHandler<,>));
scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler<,>));
});
this.For<ServiceFactory>().Use<ServiceFactory>(ctx => ctx.GetInstance);
this.For<IMediator>().LifecycleIs<TransientLifecycle>().Use<Mediator>();
// registerhandlers
this.Handlers(); // This registers all the handllers
}
We are calling same handler in parallel.
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +56
System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +12948692 System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) +16
StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) +144
StructureMap.BuildSession.GetInstance(Type pluginType) +17
MediatR.ServiceFactoryExtensions.GetInstances(ServiceFactory factory) +84
MediatR.Internal.RequestHandlerWrapperImpl2.Handle(IRequest1 request, CancellationToken cancellationToken, ServiceFactory serviceFactory) +122
MediatR.Mediator.Send(IRequest`1 request, CancellationToken cancellationToken) +258
The text was updated successfully, but these errors were encountered:
If you're only calling the RegisterMediatr function once (check this with a debugger), then this error is kinda weird. In any case, I suggest taking this up with the official MediatR repository, they'll be able to help you better. You can find that over at https://github.com/jbogard/MediatR
An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An item with the same key has already been added.
Source Error:
{
var castContext = context as IRequest;
return await this.mediator.Send(castContext, token);
}
This is what our registry looks with structure map
public RegisterMediatr()
{
this.Scan(scanner =>
{
scanner.AssemblyContainingType(typeof(IRequestHandler<,>));
scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler<,>));
});
We are calling same handler in parallel.
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +56
System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +12948692 System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) +16
StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph) +144
StructureMap.BuildSession.GetInstance(Type pluginType) +17
MediatR.ServiceFactoryExtensions.GetInstances(ServiceFactory factory) +84
MediatR.Internal.RequestHandlerWrapperImpl2.Handle(IRequest1 request, CancellationToken cancellationToken, ServiceFactory serviceFactory) +122
MediatR.Mediator.Send(IRequest`1 request, CancellationToken cancellationToken) +258
The text was updated successfully, but these errors were encountered: