lundi 29 octobre 2018

C# cast assembly class to type

Is there any way to cast a class from an external (managed) assembly to a specific interface?

I mean instead of calling MethodInfo.Invoke(instance, parameters); , do something like this

Assembly assembly = Assembly.LoadFrom(assemblyName);
System.Type type = assembly.GetType(typeName);
Object o = Activator.CreateInstance(type);
IYourType yourObj = (o as IYourType);





Aucun commentaire:

Enregistrer un commentaire