I am trying to create a console application that loads an assembly at runtime that implements an interface. The point is to create a .dll with instructions that you can change by changing the .dll.
My VS2012 solution has 3 projects: an interface, a library that implements it, and a console application. (Because of this, all three have their own namespace, maybe this is a problem?) In the library and console applications, there are links to the interface project.
After adding assemblies to, ObjectFactorythey will not be found during use GetAllInstances. They are detected during use AssembliesFromPath, but the addition does not work.
Here is my code:
var dir = "..\\..\\..\\ComputeLibrary\\bin\\Debug";
ObjectFactory.Initialize(cfg =>
{
cfg.Scan(scanner =>
{
scanner.AssembliesFromPath(dir);
scanner.AddAllTypesOf(typeof(ICompute)).NameBy(i => i.Name);
});
});
var list = ObjectFactory.GetAllInstances<ICompute>().ToList();
list.ForEach(item => item.Test());
, - , .
, , - , , .
, ? MEF - ?