I want to dynamically load a dll in a portable class library. A code equivalent to that posted below. "AssemblyName.GetAssemblyName" does not seem to be supported in a portable class library. I need an equivalent code to the below that loads assembly based on name and path. I do not know the name of the assembly at compile time.
public static object GetAssembly(string assemblyPath, string typeName)
{
AssemblyName assamblyName = AssemblyName.GetAssemblyName(assemblyPath);
Assembly assembly = Assembly.Load(assamblyName);
Type type = assembly.GetType(typeName);
object instanceOfMyType = Activator.CreateInstance(type);
return instanceOfMyType;
}
Aucun commentaire:
Enregistrer un commentaire