Totally new with this.
What im trying to achieve, is to have an interface, and people from the outside implement it and in my program load the "implementation" and bind it to my interface, so i have a few questions about this and what restrictions do i need to satisfy.
1- To the user implementing my interface, do i give him a dll which contains my interface, or just the source code and he uses it and adds his implementing code?
1.1- If 1 is true, on my program, which interface do i use? Can i use the interface loaded directly from my code or im forced to use the interface from the same DLL i gave to the user?
2- Do namespaces need to be the same? For example, the interface on my side is in namespace Server.Interface, however the one in the dll i send is just namespace Interface.
Im trying two methods to verify if an assembly implements my interface:
both inside a loop:
foreach (Type t in plugin.GetTypes())
{
Method1
if (typeof(INovedades).IsAssignableFrom(t))
{
i = (INovedades)Activator.CreateInstance(t);
break;
}
Method2
Type typeInterface = t.GetInterface("CapaDatos.ServiciosExternos.INovedades", true);
if (typeInterface != null)
{
i = (INovedades)Activator.CreateInstance(t);
break;
}
Method 1, is always false, meaning it never validates.
Method 2, finds a match, however when calling CreateInstance, it gives an exception about not being able to create an instance.
anything i should know?