I have two partial class files for the Client class. Client is registered with DI in .NET 6. I am getting an error:
InvalidOperationException: Multiple constructors accepting all given argument types have been found in type 'xxxx.Client'. There should only be one applicable constructor.
The second partial is autogenerated by NSwag.
'Client' is registered like this: builder.Services.AddHttpClient<IClient, Client>();
Instantiated like this: HttpContext.RequestServices.GetService<IClient>()
Shouldn't the ActivatorUtilitiesConstructor attribute have taken care of this?
[ActivatorUtilitiesConstructor]
public partial class Client : IClient
{
public Client(HttpClient httpClient) : this(string.Empty, httpClient) // Call generated ctor
{
}
...
and
public partial class Client : IClient
{
public Client(string baseUrl, System.Net.Http.HttpClient httpClient)
{
...
}
...