Use Activator.CreateInstance() and support multiple constructor signatures
问题 I need to instantiate a type that MUST have a IConfiguration parameter, but MAY have other parameters. Currently I use the following code: Activator.CreateInstance(myType, BindingFlags.CreateInstance, null, new object[] { configuration }, CultureInfo.InvariantCulture); myType is the type to instantiate. Written like this, it requires a constructor that has exactly one parameter of type IConfiguration . As you can see, I pass the configuration object via object array to satisfy this