Assuming I have only the class name of a generic as a string in the form of \"MyCustomGenericCollection(of MyCustomObjectClass)\" and don\'t know the assembly it comes from,
Once you parse it up, use Type.GetType(string) to get a reference to the types involved, then use Type.MakeGenericType(Type[]) to construct the specific generic type you need. Then, use Type.GetConstructor(Type[]) to get a reference to a constructor for the specific generic type, and finally call ConstructorInfo.Invoke to get an instance of the object.
Type t1 = Type.GetType("MyCustomGenericCollection");
Type t2 = Type.GetType("MyCustomObjectClass");
Type t3 = t1.MakeGenericType(new Type[] { t2 });
ConstructorInfo ci = t3.GetConstructor(Type.EmptyTypes);
object obj = ci.Invoke(null);
If you don't mind translating to VB.NET, something like this should work
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
// find the type of the item
Type itemType = assembly.GetType("MyCustomObjectClass", false);
// if we didnt find it, go to the next assembly
if (itemType == null)
{
continue;
}
// Now create a generic type for the collection
Type colType = assembly.GetType("MyCusomgGenericCollection").MakeGenericType(itemType);;
IMyCustomInterface result = (IMyCustomInterface)Activator.CreateInstance(colType);
break;
}
The MSDN article How to: Examine and Instantiate Generic Types with Reflection describes how you can use Reflection to create an instance of a generic Type. Using that in conjunction with Marksus's sample should hopefully get you started.