Skip to content
This repository was archived by the owner on Apr 26, 2020. It is now read-only.
This repository was archived by the owner on Apr 26, 2020. It is now read-only.

Ninject binding issue with IDiagnosticsProvider #17

@vatirim

Description

@vatirim

Hi,

it all worked when I used the Nancy internal IoC. With this lib I now get this exception:

A first chance exception of type 'Ninject.ActivationException' occurred in Ninject.dll
Additional information: Error activating IntPtr
No matching bindings are available, and the type is not self-bindable.
Activation path:
4) Injection of dependency IntPtr into parameter method of constructor of type Func{IRouteCache}
3) Injection of dependency Func{IRouteCache} into parameter routeCacheFactory of constructor of type DefaultRouteCacheProvider
2) Injection of dependency IDiagnosticsProvider into parameter diagnosticProviders of constructor of type DefaultDiagnostics

  1. Request for IDiagnostics

I am using the latest stable nuget packages:

  • Nancy 0.23.2
  • Nancy.Bootstrappers.Ninject 0.23.2
  • Ninject 3.0.1.10
  • Ninject.Extensions.ChildKernel 3.0.0.5

I have a workaround. Injecting this bind in the bootstrapper:

protected override void ConfigureApplicationContainer(IKernel existingContainer)
{
  base.ConfigureApplicationContainer(existingContainer);
  existingContainer.Rebind<Func<IRouteCache>>().ToMethod(ctx =>
     () => ctx.Kernel.Get<IRouteCache>());
   // A Bind might be enough.
}

The problem might be that Ninject cannot inject into constructor parameters of type Func<Interface> as is the case in DefaultRouteCacheProvider.

Am I doing anything wrong or am I just the first to notice this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions