In my global.asax file I have a dependency set up between an interface and a class. The injection always works and there is no issue with the setup.
In a model binder, in the same solution, I am trying to get the concrete class mapped to that interface thus
IKernel kernel = new StandardKernel();
var samurai = kernel.Get<Samurai>();
For some reason this does not work and I get an error saying “object initialisation null” or something to that effect. As I understand it this makes sense since this kernel I just created is a new object not linked to the object created in the global.asax. How do I get the one in the global.asax or am I doing something else wrong?
In global.asax.cs, I used static variable for this kind of situation.
And I think you are trying to get reference to interface i.e., ISamurai which inturn gives reference to actual object Samurai.