I edited your question because it was far too long and verbose (3000 chars).
Answer to Question 1
To load dlls dynamically, look at this answer. It uses reflection to iterate over every type in the assembly and uses Activator.CreateInstance()
to instantiate the classes.
For your plugin system I would create something like:
In your .exe:
public interface IPlugin
{
void DoSomething();
}
public class A : IPlugin
{
public virtual void DoSomething() {}
}
public class B : IPlugin
{
public virtual void DoSomething() {}
}
public class C : IPlugin
{
public virtual void DoSomething() {}
}
public class D : IPlugin
{
public virtual void DoSomething() {}
}
In a Dll:
public class NewA : A
{
public override void DoSomething() { base.DoSomething() }
}
public class NewB : B
{
public override void DoSomething() { base.DoSomething() }
}
public class NewC : C
{
public override void DoSomething() { base.DoSomething() }
}
public class NewD : D
{
public override void DoSomething() { base.DoSomething() }
}
In your client code, code against IPlugin
. Your client code does not know about the concrete classes A
, B
, C
, D
.
Load the classes that you want from the dlls you have and inject them into IPlugin
Answer to Question 2
You can have classes with the same class name as long as they are in separate namespaces, you cannot have classes with the same name in the same namespace. In your case, they ought to be in different namespaces so you are okay.