I'm developing an application using IoC and Ninject for dependency injection, and I came across the following problem:
When uploading my application to the server I get the following error:
Can anyone help me with how to resolve this error?
IoC.Install Method
public static void Install()
{
DILoader.Install(
(tInterface, tClass) => IoC.Register(tInterface, tClass),
(tInterface, tClass) => IoC.RegisterInSingletonScope(tInterface, tClass),
(tInterface, tClass) => IoC.RegisterInThreadScope(tInterface, tClass)
);
}
This is where I load the Assemblies
public static void LoadAssemblies()
{
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
loadedAssemblies
.SelectMany(x => x.GetReferencedAssemblies())
.Distinct()
.Where(y => loadedAssemblies.Any((a) => a.FullName == y.FullName) == false)
.ToList()
.ForEach(x => loadedAssemblies.Add(AppDomain.CurrentDomain.Load(x)));
}
Here is where I call these methods
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
LoadAssemblies();
IoC.Install();
}
Method where I register the binds
public class NinjectIoCContainer : IIocContainer
{
private IKernel kernel;
private IKernel Kernel
{
get
{
if (kernel == null) {
kernel = new StandardKernel();
}
return kernel;
}
}
public void Register(Type tInterface, Type tClass)
{
Kernel.Bind(tInterface).To(tClass);
}
public void RegisterInSingletonScope(Type tInterface, Type tClass)
{
Kernel.Bind(tInterface).To(tClass).InSingletonScope();
}
public void RegisterInThreadScope(Type tInterface, Type tClass)
{
Kernel.Bind(tInterface).To(tClass).InThreadScope();
}
public TInterface Resolve<TInterface>()
{
return Kernel.Get<TInterface>();
}
}
}
To bind it takes the classes that have the attribute as the example below
[InstanceIoC]
public class UCManterUsuario : IManterManterUsuario
{