Search code examples
ninjectninject-2

Ninject get method set constructor argument to null


I am using Ninject for implementing IoC/DI in my application. It has been working well in the whole application except one case, where i am setting a constructor argument of type User Defined Class.

This class has four properties, all of them are of type user defined type, All of them are serialized enums.

Now when i resolve the dependency of kernel, it throws me the exception as constructor arguments values set to null. I don't know why is it.

Is it because of seriazlizeable enums or something else. There is no way i could change my types, so please suggest me something in the context where i don't need to change the types.

Edit

IManager manager = GlobalData.Kernel.Get<IManager> (new ConstructorArgument("context", Context)); 
// Context Class code is here 
public class Context { 
    public string ContextCode { get; set; } 
    public Module Module { get; set; } 
    public Screen Screen { get; set; } } 

Module and Screen are Serializable Enums


Solution

  • That's because your Context passed to Get as constructor argument is Null.