I have just downloaded the latest version of Ninject and replaced our existing Ninject.Core and Ninject.Condidtions assemblies with the single Ninject.dll (CF builds if that makes a difference). All has gone smoothly until I get to:
kernel.Components.Connect<IMemberSelector>(new MyMemberSelector());
Which is implemented:
public class...
Hello all,
Recently I've switched to Ninject 2.0 release and started getting the following error:
Error occured: Error activating SomeController
More than one matching bindings are available.
Activation path:
1) Request for SomeController
Suggestions:
1) Ensure that you have defined a binding for SomeController only once.
Howev...
When an object in Ninject is bound with InTransientScope(), the object isn't placed into the cache, since it's, er, transient and not scoped to anything.
When done with the object, I can call kernel.Release(obj); this passes through to the Cache where it retrieves the cached item and calls Pipeline.Deactivate using the cached entry.
...
My web app solution consists of 3 projects:
Web App (ASP.NET MVC)
Business Logic Layer (Class Library)
Database Layer (Entity Framework)
I want to use Ninject to manage the lifetime of the DataContext generated by the Entity Framework in the Database Layer.
The Business Logic layer consists of classes which reference repositories (...
Can you use Ninject 2.0 with VS2010 RC1?
...
I'm using MEF with ASP.NET MVC as demonstrated at http://blog.maartenballiauw.be/post/2009/06/17/Revised-ASPNET-MVC-and-the-Managed-Extensibility-Framework-(MEF).aspx.
When I try to use Ninject, it seems that nothing gets injected. I did some debugging, and when I reverted to the original controller factory the injection worked.
What n...
I want to use conditional binding in ninject, based on passed parameters. I have something like below:
public class Subject
{
}
public interface ITarget
{
}
public class Target1 : ITarget
{
}
public class Target2 : ITarget
{
}
And now I need to instantiate ITarget interface:
public void MethodName(IKernel kernel)
{
...
I've updated a project to VS2010 and MVC2 from VS2008 and MVC1. I'm having problems with Ninject not finding controllers within Areas
Here is my global.asax.cs file:
namespace Website
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : Ninje...
We are using the beloved Ninject+Ninject.Web.Mvc with MVC 2 and are running into some problems. Specifically dealing with 404 errors. We have a logging service that logs 500 errors and records them. Everything is chugging along just perfectly except for when we attempt to enter a non-existent controller. Instead of getting the desire...
In Ninject 1.0 I had following binding definitions:
Bind<ITarget>().To<Target1>().Only(When.Context.Variable("variable").EqualTo(true));
Bind<ITarget>().To<Target2>();
Given such bindings I had calls:
ITarget target = kernel.Get<ITarget>(With.Parameters.ContextVariable("variable", true));
ITarget target = kernel.Get<ITarget>(With.Par...
In middle of application when calling following line:
var component = _Kernel.Get<IComponent>();
I'm getting TargetInvocationException. IComponent is a Form.
at
System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
invokeAttr, Binder binder, Object[]
parameters, CultureInfo culture) at
System.Reflection.Construc...
Hi guys,
I am new to ninject, I am wondering how I can run custom initizlisation code when constructing the injected objects? ie. I have a Sword class which implements IWeapon, but I want to pass an hit point value to the Sword class constructor, how do I achieve that? Do I need to write my own provider?
A minor question, IKernel kerne...
I'm hitting paralysis by analysis I think...
Which should I go for for my first IOC container: Autofac or Ninject?
(Just want an open source, nice and simple, IOC container)
...
Hi,
I'm getting confused in the doco how I should be setting up Ninject. I'm seeing different ways of doing it, some v2 versus v1 confusion probably included...
Question - What is the best way in my WinForms application to set things up for NInject (i.e. what are the few lines of code required). I'm assuming this would go into the Ma...
Getting going now with NInject... :)
For a WinForms application, and in particular the business logic classes used within it, is there a rule of thumb in terms of which Classes once should hook up using IOC? For example if you have a Domain Model which is modelled by C# classes is the concept that all classes should be wired together ...
Resolving a class that has multiple constructors with NInject doesn't seem to work.
public class Class1 : IClass
{
public Class1(int param) {...}
public Class1(int param2, string param3) { .. }
}
the following doesn’t seem to work:
IClass1 instance =
IocContainer.Get<IClass>(With.Parameters.ConstructorArgument(“param”, 1));
The...
Hi,
Just trying to still get my head around IOC principles.
Q1: Static Methods - Should util classes with static helper methods be wired up with IOC?
For example if I have a HttpUtils class with a number of static methods, should I be trying to pass it to other business logic classes via IOC?
Follow on questions for this might be:
...
I'm evaluating ninject2 but can't seem to figure out how to do lazy loading other than through the kernel.
From what I can see that kind of defeats the purpose of using the [Inject] attributes.
Is it possible to use the InjectAttribute but get lazy loading? I'd hate to force complete construction of an object graph every time I instant...
I'm trying to use Ninject for dependency injection in my MVP application. However, I have a problem because I have two types that depend on each other, thus creating a cyclic dependency. At first, I understand that it was a problem, because I had both types require each other in their constructors. Therefore, I moved one of the dependenc...
I have set up a NInject (using version 1.5) binding like this:
Bind<ISessionFactory>().ToMethod<ISessionFactory>(ctx =>
{
try
{
// create session factory, might fail because of database issues like wrong connection string
}
catch (Exception e)
{
throw new DatabaseException(e);
}
}).Using<Singleto...