{"action":"closed","issue":{"url":"https://api.github.com/repos/Particular/NServiceBus/issues/3197","labels_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3197/labels{/name}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3197/comments","events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3197/events","html_url":"https://github.com/Particular/NServiceBus/issues/3197","id":121513132,"number":3197,"title":"SLAMonitoring crashes during initialization if more than one IConfigureThisEndpoint implementation is found","user":{"login":"jjanuszkiewicz","id":3861175,"avatar_url":"https://avatars.githubusercontent.com/u/3861175?v=3","gravatar_id":"","url":"https://api.github.com/users/jjanuszkiewicz","html_url":"https://github.com/jjanuszkiewicz","followers_url":"https://api.github.com/users/jjanuszkiewicz/followers","following_url":"https://api.github.com/users/jjanuszkiewicz/following{/other_user}","gists_url":"https://api.github.com/users/jjanuszkiewicz/gists{/gist_id}","starred_url":"https://api.github.com/users/jjanuszkiewicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjanuszkiewicz/subscriptions","organizations_url":"https://api.github.com/users/jjanuszkiewicz/orgs","repos_url":"https://api.github.com/users/jjanuszkiewicz/repos","events_url":"https://api.github.com/users/jjanuszkiewicz/events{/privacy}","received_events_url":"https://api.github.com/users/jjanuszkiewicz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-10T15:37:15Z","updated_at":"2015-12-18T08:20:30Z","closed_at":"2015-12-18T08:20:30Z","body":"In NServiceBus 5.2.11 my endpoint fails to start with the following error:\r\n\r\n    2015-12-10 10:58:36,175 [4] FATAL NServiceBus.GenericHost - Exception when starting endpoint.\r\n    System.InvalidOperationException: Sequence contains more than one matching element\r\n       at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)\r\n       at NServiceBus.Features.SLAMonitoring.TryGetSlaFromAttribute(FeatureConfigurationContext config, TimeSpan& sla) in C:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Monitoring\\SLA\\SLAMonitoring.cs:line 56\r\n       at NServiceBus.Features.SLAMonitoring.TryGetSLA(FeatureConfigurationContext context, TimeSpan& endpointSla) in C:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Monitoring\\SLA\\SLAMonitoring.cs:line 46\r\n       at NServiceBus.Features.SLAMonitoring.Setup(FeatureConfigurationContext context) in C:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Monitoring\\SLA\\SLAMonitoring.cs:line 28\r\n       at NServiceBus.Features.FeatureActivator.ActivateFeature(FeatureState featureState, IEnumerable`1 featuresToActivate, FeatureConfigurationContext context) in C:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Features\\FeatureActivator.cs:line 235\r\n       at NServiceBus.Features.FeatureActivator.SetupFeatures(FeatureConfigurationContext context) in C:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Features\\FeatureActivator.cs:line 116\r\n       at NServiceBus.Configure.Initialize() in C:\\BuildAgent\\work\\3206e2123f54fce4\\src\\NServiceBus.Core\\Configure.cs:line 115\r\n       at NServiceBus.GenericHost.PerformConfiguration(Action`1 moreConfiguration) in c:\\BuildAgent\\work\\a3de8759ee491634\\src\\NServiceBus.Hosting.Windows\\GenericHost.cs:line 119\r\n       at NServiceBus.GenericHost.Start() in c:\\BuildAgent\\work\\a3de8759ee491634\\src\\NServiceBus.Hosting.Windows\\GenericHost.cs:line 58\r\n\r\nThe SLAMonitoring.cs:line 56 has this:\r\n\r\n    var configType = config.Settings\r\n        .GetAvailableTypes()\r\n        .SingleOrDefault(t => typeof(IConfigureThisEndpoint).IsAssignableFrom(t) && !t.IsInterface);\r\n\r\nMy endpoint has a `IConfigureThisEndpoint` implementation which inherits from a base (abstract) endpoint configuration class shared with other endpoints. It also has another (unused in this endpoint) `IConfigureThisEndpoint` implementation in one of the scanned assemblies, so there are in fact multiple `IConfigureThisEndpoint`s in the scanned types, but only one is actually used (I use the NSB host and specify the correct `EndpointConfigurationType` in its config file).\r\n\r\nI think this is a bug in NSB 5.2 and SLAMonitoring should not attempt to locate `IConfigureThisEndpoint` itself, rather it should use the one actually used in the endpoint. No other feature crashes due to the presence of multiple `IConfigureThisEndpoint`s. Also, previous NSB version (4.6) did not crash like this, so this is a regression."}}