Service discovery with DNS SRV is broken when using AutoFac
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
When using AutoFac as a DI container, the following error is encountered when using `.AddDnsSrvServiceEndpointProvider()`:
```
Autofac.Core.DependencyResolutionException: Cannot choose between multiple constructors with equal length 1 on type 'DnsClient.LookupClient'. Select the constructor explicitly, with the UsingConstructor() configuration method, when the component is registered.
at Autofac.Core.Activators.Reflection.MostParametersConstructorSelector.SelectConstructorBinding(BoundConstructor[] constructorBindings, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ReflectionActivator.b__13_0(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
```
The workaround is to re-register the `LookupClient` as below:
`.AddSingleton(_ => new LookupClient())`
however this should work out-of-the box without resorting to this workaround.
Contributor guide
Assessment
This issue has not been assessed yet.