Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling for parameter name mismatches #26

Open
floyd-may opened this issue May 8, 2015 · 0 comments
Open

Handling for parameter name mismatches #26

floyd-may opened this issue May 8, 2015 · 0 comments

Comments

@floyd-may
Copy link

If a factory interface's parameter names don't match the constructor arguments for the constructed type, you get an exception message that looks like this:

Ninject.ActivationException was unhandled by user code
  Message=Error activating <parameter type>
No matching bindings are available, and the type is not self-bindable.
Activation path:
  2) Injection of dependency <parameter type> into parameter <constructor argument name> of constructor of type <factory-created type>
  1) Request for <factory-created type>

Suggestions:
  1) Ensure that you have defined a binding for <parameter type>.
  2) If the binding was defined in a module, ensure that the module has been loaded into the kernel.
  3) Ensure you have not accidentally created more than one kernel.
  4) If you are using constructor arguments, ensure that the parameter name matches the constructors parameter name.

It's attempting to resolve the parameter from the container instead of passing the parameter through. Either of these would be fantastic:

  1. Add rudimentary handling for mismatched parameter names so that if the types are compatible, names don't have to match
  2. Provide better exception messaging, along the lines of "Unable to resolve parameter named in constructor parameter of type "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant