I have the following class:
public class Errors { private readonly string _connectionString; public Errors(string connectionString) { _connectionString = connectionString; } }
I am trying to register using Autofac like this:
builder.RegisterType<Errors>().WithParameter("connectionString", System.Configuration.ConfigurationManager.ConnectionStrings["myConn"].ConnectionString);
This object is entered into another object, but it is always zero. Further, in case of an exception, the following error message is displayed:
Cannot choose between multiple constructors with equal length 1 on type 'System.String'. Select the constructor explicitly, with the UsingConstructor() configuration method, when the component is registered.
I tried registering with UseConstructor and WithParameter, and no changes occurred.
source share