Hi

I am trying to load at runtime a class from a dll,
knowing an interface that the class implements.

I can load and create an instance of that class,
but only as an Object... I cannot convert it to
my interface.

The error is: System.InvalidCastException

The code is:

Assembly a=Assembly.LoadFrom(("a.dll");

Type theType = a.GetType("Type1");

Type interfaceType=theType.GetInterface("iType1");
Console.WriteLine("implements {0}",interfaceType);

Object o=Activator.CreateInstance(theType);
Console.WriteLine("loaded as an object: {0}",o);

iType1 i = (iType1) o;
Console.WriteLine(i);

Both the dll and the exe have the same namespace,
and they both know the interface iType1. And both
the interface and the class are public...

Thanks in advance,