I Use Ninject For DIP in My Mvc App and I work with it but I want to Load Some dll Files into My Ninject Kernel in ReportController with below code:
private readonly IKernel _kernel;
public ReportController(IKernel kernel)
{
_kernel = kernel;
}
public ActionResult Index()
{
var directoryInfo = new DirectoryInfo(@"D:\Project\ReportDlls");
var modules = directoryInfo.GetFiles("*.dll");
foreach (var m in modules)
{
var assembly = Assembly.LoadFile(m.FullName);
_kernel.Load(assembly);
}
And I Read from kernel with below code but its return null routesProviders....Why??
var routesProviders = _kernel.GetAll<IReport>();
foreach (var rp in routesProviders)
{
if (rp.GetType().Name == "DailyResult")
{
var f = rp.GetType();
}
}
My Interface is IReport and My Dll Derived from IReport and In class IocModule in my dll i wrote Kernel.Bind<IReport>().To<DailyResult>();
But Its Not work....???
Aucun commentaire:
Enregistrer un commentaire