Sequence contains more than one member error when using binding with multiple constructor parameters
Using MVC5
with version ninject
3.2 I noticed that it is ninject
throwing this error
Sequence contains more than one element
on resolution / injection of dependency
I have an email service that uses sendgrid
to send emails from an application MVC 5
running inAzure WebSites
if i register a service like in ninjectwebcommon it works
var sgUserName = ConfigurationManager.AppSettings["SG_UserName"];
var sgPassword = ConfigurationManager.AppSettings["SG_Password"];
//Register email service
kernel.Bind<IEmailService>()
.To<EmailService>()
.WithConstructorArgument("userName", sgUserName)
.WithConstructorArgument("password", sgPassword);
Below is the code
Sequence contains more than one element
on resolution / injection of dependency. Not sure if this is a known issue or not.
var sgUserName = ConfigurationManager.AppSettings["SG_UserName"];
var sgPassword = ConfigurationManager.AppSettings["SG_Password"];
//Register email service
kernel.Bind<IEmailService>()
.To<EmailService>()
.WithConstructorArgument(sgUserName)
.WithConstructorArgument(sgPassword);
source to share
I know this is old, but I want to be responsible for anyone who happens to have this error. It might be okay to leave ArgumentName when there is only one.
I would not want and have not. ArgumentName is required for each when there is more than one argument.
This is not really a problem, which only requires the name and the .WithConstructorsArgument argument.
source to share