Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing an exception using multiple ICapSubscribe services #38

Closed
jex518 opened this issue Aug 21, 2017 · 3 comments

Comments

@jex518
Copy link

commented Aug 21, 2017

see CAP/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs

private static void AddSubscribeServices(IServiceCollection services)
{
var consumerListenerServices = new Dictionary<Type, Type>();
foreach (var rejectedServices in services)
{
if (rejectedServices.ImplementationType != null
&& typeof(ICapSubscribe).IsAssignableFrom(rejectedServices.ImplementationType))
// here throw exception
consumerListenerServices.Add(typeof(ICapSubscribe), rejectedServices.ImplementationType);
}

@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 21, 2017

How can I reproduce this exception?

@jex518

This comment has been minimized.

Copy link
Author

commented Aug 21, 2017

i used :
public class CabSubsService : ICabSubsService, ICapSubscribe
public class CabSubsService2 : ICabSubsService2, ICapSubscribe

in startup.cs
services.AddTransient<ICabSubsService, CabSubsService>();
services.AddTransient<ICabSubsService2, CabSubsService2>();

i ran app,throw an error:
ArgumentException: An item with the same key has already been added. Key: DotNetCore.CAP.ICapSubscribe

yang-xiaodong added a commit that referenced this issue Aug 21, 2017
@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 21, 2017

Thanks for your feedback, this is a bug.
I have fixed it on version 2.0.0-preview-20091963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.