Note: Now that I've typed this out, I have to apologize for the super long question, however, I think all the code and information presented here is in some way relevant.
Okay, I'm getting odd "Session Is Closed" errors, at random points in my ASP.NET webforms application. Today, however, it's finally happening in the same place over ...
I'm using asp.net MVC 2 and Ninject 2.
The setup is very simple.
Controller calls service that calls repository.
In my controller I use inject to instantiate the service classes with no problem. But the service classes don't instantiate the repositories, giving me NullReferenceException.
public class BaseController : Controller
{
...
I'm using Ninject 2.0 for the .Net 3.5 framework. I'm having difficulty with singleton binding.
I have a class UserInputReader which implements IInputReader. I only want one instance of this class to ever be created.
public class MasterEngineModule : NinjectModule
{
public override void Load()
{
// usin...
I have a class with a public constructor:
public MasterEngine(IInputReader inputReader)
{
this.inputReader = inputReader;
graphicsDeviceManager = new GraphicsDeviceManager(this);
Components.Add(new GamerServicesComponent(this));
}
How can I inject dependencies like graphicsDeviceManager and new Gam...
I'm having difficulty integrating Ninject with XNA.
static class Program
{
/**
* The main entry point for the application.
*/
static void Main(string[] args)
{
IKernel kernel = new StandardKernel(NinjectModuleManager.GetModules());
CachedContentLoader content = kernel.Get<CachedContentLoader>(); //...
My case it is Ninject 2.
// normal explicit dispose
using (var dc = new EFContext)
{
}
But sometimes I need to keep the context longer or between function calls.
So I want to control this behavior through IoC scope.
// if i use this way. how do i make sure object is disposed.
var dc = ninject.Get<IContext>()
// i cannot use this ...
Hi,
I'M just trying to get started with Ninject 2 and ASP.NET MVC 2. I have followed this tutorial http://www.craftyfella.com/2010/02/creating-aspnet-mvc-2-controller.html to create a Controller Factory with Ninject and to bind a first abstract to a concrete implementation. Now I want to load a repository type from another assembly (wher...
I'm doing shared hosting with GoDaddy and I developed a sample ASP.NET MVC app using Castle Windsor and unfortunately, it didn't work in a medium trust setting. Specifically, I got this error: "[SecurityException: That assembly does not allow partially trusted callers"... etc. GoDaddy is sadly not flexible in their trust policy.
I'm not...
Given the class Ninja, with a specified binding in the Ninject kernel I can resolve an object doing this:
var ninja = ninject.Get<Ninja>();
But why can't I do this:
Type ninjaType = typeof(Ninja);
var ninja = ninject.Get<ninjaType>();
What's the correct way of specifying the type outside the call to Get?
...
Is anyone out there using the Prism framework with Ninject instead of Unity? I need some functionality Unity isn't supporting yet, and I've decided to switch the IoC container to Ninject. I'm struggling a bit with the replace though..
What I need to use from Prism is the EventAggregator and the RegionManager. I have seen this sample th...
I want to use Ninject to use in a non MVC ASP.NET 3.5 web application.
Can someone write please what do I need to download from ninject home site and what steps I need to take (what ddls I need to reference etc.)? I also want to use Moq objects.
...
Well, I don't know if "strong naming" is the right term, but what I want to do is as follows.
Currently I use ConstructorArgument like e.g. this:
public class Ninja
{
private readonly IWeapon _weapon;
private readonly string _name;
public Ninja(string name, IWeapon weapon)
{
_weapon = weapon;
_name = ...
We've begun using Dependency Injection recently, and we've chosen Ninject 2 (for now) as our IoC Container. As I refactor our solution to incorporate DI principles, I've run into something that bugs me a little, and I'm wondering if there's an easy way to get around it.
For our data layer, we have a whole bunch of data-access classes t...
When using Ninjects ConstructorArgument you can specify the exact value to inject to specific parameters. Why can't this value be null, or how can I make it work? Maybe it's not something you'd like to do, but I want to use it in my unit tests.. Example:
public class Ninja
{
private readonly IWeapon _weapon;
public Ninja(IWeapo...
Hello,
In my previous project we used NHibernate and Spring.NET.
Transactions were handled by adding [Transaction] attribute to service methods.
In my current project I'm using NHibernate and NInject 2 and I was wondering if it's possible to solve transaction handling using "Ninject.Extensions.Interception" and similar [Transaction] ...
How do I wire up dependencies where the dependency is in the form of a collection ??
For Example:
public class Ninja {
public List<IShuriken> Shurikens {get;set;}
public IKatana Katana {get;set;}
public void Attack()
{
// some code goes here to use weapons and kill people
}
}
How do i use a container like Ninject in a case like t...
How can you instantiate a Controller that has an int argument?
Using Ninject..
My HomeController has a constructor like this:
private int _masterId;
Public HomeController(int masterId){
_masterId = masterId;
}
I created a controller factory like this:
public class NinjectControllerFactory : DefaultControllerFactory
...
If I am working on a class library how do I make use of Ninject here? i.e., from the internal class library point of view and also from the client code?
For example:
should the class library have its own IOC set up, or should it always assume the client code will supply?
if no (ie it's up to the client to have the IOC in place) then w...
How do I handle classes with static methods with Ninject?
That is, in C# one can not have static methods in an interface, and Ninject works on the basis of using interfaces?
My use case is a class that I would like it to have a static method to create an
unpopulated instance of itself.
EDIT 1
Just to add an example in the Topolog...
Hello,
I was trying Ninject in a Asp.net Mvc application and I was wondering what the best practice is for using Ninject if you have more than 1 project in your solution.
I guess all projects need some kind of Loader which you initialize in the global.asax?
Kind regards,
Pickels
...