SignalR/SignalR · error · InvalidOperationException
Multiple activators for type {0} are registered. Please call
Error message
Multiple activators for type {0} are registered. Please call GetServices instead. What it means
Thrown by DefaultDependencyResolver.GetService when more than one activator is registered for the requested Type. GetService is single-instance and ambiguous when multiple registrations exist; the resolver refuses to silently pick one and directs the caller to GetServices (plural) instead.
Source
Thrown at src/Microsoft.AspNet.SignalR.Core/DefaultDependencyResolver.cs:128
}
public virtual object GetService(Type serviceType)
{
if (serviceType == null)
{
throw new ArgumentNullException("serviceType");
}
IList<Func<object>> activators;
if (_resolvers.TryGetValue(serviceType, out activators))
{
if (activators.Count == 0)
{
return null;
}
if (activators.Count > 1)
{
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_MultipleActivatorsAreaRegisteredCallGetServices, serviceType.FullName));
}
return Track(activators[0]);
}
return null;
}
public virtual IEnumerable<object> GetServices(Type serviceType)
{
IList<Func<object>> activators;
if (_resolvers.TryGetValue(serviceType, out activators))
{
if (activators.Count == 0)
{
return null;
}
return activators.Select(Track).ToList();
}
return null;View on GitHub (pinned to 693053b89a)
Solutions
- Use GetServices(serviceType) to retrieve all registered instances when multiples are expected.
- If a single instance is required, deregister duplicates so only one activator remains.
- Audit Register calls (including third-party HostStartup classes) for the conflicting type.
Example fix
// before var single = resolver.GetService(typeof(IMyService)); // after var all = resolver.GetServices(typeof(IMyService)); var single = all.FirstOrDefault();
Defensive patterns
Strategy: validation
Validate before calling
var all = resolver.GetServices(serviceType).ToList(); var single = all.Count == 1 ? all[0] : all.FirstOrDefault();
Type guard
var services = resolver.GetServices(serviceType)?.ToList() ?? new List<object>(); object single = services.Count > 1 ? null : services.FirstOrDefault();
Try / catch
try
{
return resolver.GetService(serviceType);
}
catch (InvalidOperationException)
{
// multiple registrations; fall back to plural resolution
return resolver.GetServices(serviceType).FirstOrDefault();
} Prevention
- Use GetServices (plural) when multiple registrations are expected.
- Audit Register calls including third-party HostStartup modules for duplicate types.
- Write a composition-root test that asserts at most one activator per single-instance service.
When it happens
Trigger: Registering two or more factories for the same Type via Register, then calling GetService on that Type.
Common situations: Multiple modules/libraries each register the same service type (e.g., several IHubPipeline modules registered as the pipeline), or a plugin composition that double-registers.
Related errors
- serviceType
- DisconnectTimeout cannot be configured after the KeepAlive.
- request
- hubIncomingInvokerContext
- Outgoing authorization can only be required for an entire Hu
AI-assisted analysis of SignalR/SignalR@693053b89a (2026-08-13).
Data as JSON: /api/errors/04e2c74e8f6f9e90.
Report an issue: GitHub.