Problem using Ninject.MVC3 NuGet package

897 views
Skip to first unread message

Roland Tepp

unread,
Mar 18, 2011, 10:10:19 AM3/18/11
to nin...@googlegroups.com
Hi,

It may well be that I am just doing something plain wrong, but at the moment I can't for the life of me figure out what.

I've installed the Ninject.MVC3 2.2.1.1 via NuGet and when I start my application, I get the error, that I've pasted in to the message below.

I would appreciate it, if someone could point me at the correct direction...

Server Error in '/' Application.

Error activating IResolutionRoot
More than one matching bindings are available.
Activation path:
 2) Injection of dependency IResolutionRoot into parameter resolutionRoot of constructor of type NinjectDependencyResolver
 1) Request for IDependencyResolver

Suggestions:
 1) Ensure that you have defined a binding for IResolutionRoot only once.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Ninject.ActivationException: Error activating IResolutionRoot
More than one matching bindings are available.
Activation path:
 2) Injection of dependency IResolutionRoot into parameter resolutionRoot of constructor of type NinjectDependencyResolver
 1) Request for IDependencyResolver

Suggestions:
 1) Ensure that you have defined a binding for IResolutionRoot only once.


Source Error:

Line 21:         {
Line 22:             DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));
Line 23:             bootstrapper.Initialize(CreateKernel);
Line 24:         }
Line 25: 

Source File: C:\Projects\ELS\Admin\Web\ElsAdmin\App_Start\NinjectMVC3.cs    Line: 23

Stack Trace:

[ActivationException: Error activating IResolutionRoot
More than one matching bindings are available.
Activation path:
  2) Injection of dependency IResolutionRoot into parameter resolutionRoot of constructor of type NinjectDependencyResolver
  1) Request for IDependencyResolver

Suggestions:
  1) Ensure that you have defined a binding for IResolutionRoot only once.
]
   Ninject.KernelBase.Resolve(IRequest request) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:372
   Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Targets\Target.cs:179
   Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Targets\Target.cs:147
   Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:97
   Ninject.Activation.Providers.<>c__DisplayClass2.<Create>b__1(ITarget target) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81
   System.Linq.WhereSelectArrayIterator`2.MoveNext() +85
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +217
   System.Linq.Enumerable.ToArray(IEnumerable`1 source) +78
   Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81
   Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:157
   Ninject.KernelBase.<Resolve>b__7(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:375
   System.Linq.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x) +32
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +151
   System.Linq.<CastIterator>d__b1`1.MoveNext() +92
   System.Linq.Enumerable.Single(IEnumerable`1 source) +196
   Ninject.ResolutionExtensions.Get(IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:37
   Ninject.Web.Mvc.Bootstrapper.CreateDependencyResolver() in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\Bootstrapper.cs:92
   Ninject.Web.Mvc.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\Bootstrapper.cs:68
   ElsAdmin.App_Start.NinjectMVC3.Start() in C:\Projects\ELS\Admin\Web\ElsAdmin\App_Start\NinjectMVC3.cs:23

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +72
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +335
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   WebActivator.BaseActivationMethodAttribute.InvokeMethod() +241
   WebActivator.ActivationManager.RunActivationMethods() +362
   WebActivator.ActivationManager.RunPreStartMethods() +43
   WebActivator.ActivationManager.Run() +69

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8972240
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

Remo Gloor

unread,
Mar 19, 2011, 10:43:59 AM3/19/11
to ninject
Do you use other extensions? I think using the context preservation
extension and mvc can cause his problem in this case try add the
following binding:
this.Rebind<IResolutionRoot>().To<ContextPreservingResolutionRoot>();

We defenately have to ensure all extensions using IKernel/
IResolutionRoot work better side a side in the next release.

On 18 Mrz., 15:10, Roland Tepp <luol...@gmail.com> wrote:
> Hi,
>
> It may well be that I am just doing something plain wrong, but at the moment
> I can't for the life of me figure out what.
>
> I've installed the Ninject.MVC3 2.2.1.1 via NuGet and when I start my
> application, I get the error, that I've pasted in to the message below.
>
> I would appreciate it, if someone could point me at the correct direction...
>
> Server Error in '/' Application.
> ------------------------------
>  *Error activating IResolutionRoot
> More than one matching bindings are available.
> Activation path:
>  2) Injection of dependency IResolutionRoot into parameter resolutionRoot of
> constructor of type NinjectDependencyResolver
>  1) Request for IDependencyResolver
>
> Suggestions:
>  1) Ensure that you have defined a binding for IResolutionRoot only once.
> *  * Description: *An unhandled exception occurred during the execution of
> the current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
>
> * Exception Details: *Ninject.ActivationException: Error activating
> IResolutionRoot
> More than one matching bindings are available.
> Activation path:
>  2) Injection of dependency IResolutionRoot into parameter resolutionRoot of
> constructor of type NinjectDependencyResolver
>  1) Request for IDependencyResolver
>
> Suggestions:
>  1) Ensure that you have defined a binding for IResolutionRoot only once.
>
> *Source Error:*
>
>   Line 21:         {
> Line 22:             DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule));Line 23:             bootstrapper.Initialize(CreateKernel);Line 24:         }
> Line 25:
>
> * Source File: * C:\Projects\ELS\Admin\Web\ElsAdmin\App_Start\NinjectMVC3.cs
> *    Line: * 23
>
> *Stack Trace:*

Roland Tepp

unread,
Mar 20, 2011, 9:12:10 AM3/20/11
to nin...@googlegroups.com
Yes, it seems you are right, I do use context preserving resolution root extension, but where do I put this Rebind?

It does not seem to help if I put it into RegisterServices method.

And since I use NuGet version, I do not have access to modify the source of Bootstrapper...
Reply all
Reply to author
Forward
0 new messages