Ninject core binding looks like this: -
Create XML as below: -
<module name="myXmlConfigurationModule"> <bind service="MyNamespace.IMyService, MyAssembly" to="MyNamespace.MyServiceImplementation, MyAssembly" /> <bind service="MyNamespace.IMyOtherService, MyAssembly" to="MyNamespace.MyOtherServiceImplementation, MyAssembly" /> </module>
Then the code: -
using Ninject; enter code here class ABC { public void CallingMethodUsingNinject() { private IKernel kernel= new StandardKernel(); kernel.Load("yourXmlFileName.xml"); bool ismodule = kernel.HasModule("myXmlConfigurationModule");
Some of them may run into a problem due to the properties of the XML file, so you need to change the settings of the xml file. IMyService activation error There are no corresponding bindings, and the type is not self-switching. Solution: -Do not forget to set Copy to output Directory properties of this xml file to copy, if it is newer, so that it can be copied to automatically display the directory
Read more: -read https://www.packtpub.com/sites/default/files/9781782166207_Chapter_02.pdf
source share