Disable implicit binding/injection of non explicitly bound classes in Ninject 2+

后端 未结 2 2083
旧时难觅i
旧时难觅i 2021-02-09 02:44

If you request an unbound object from NInject, then the default behaviour is (if a suitable constructor is available) appears to be to create an instance of the appropriate obje

2条回答
  •  日久生厌
    2021-02-09 03:10

    Remove the SelfBindingResolver from the kernel components after creation:

    kernel.Components.RemoveAll();
    kernel.Components.Add();
    

提交回复
热议问题