I want to dynamically load dll files锛宧ow to use Assembly?
webform i can do like this:
Assembly asm = Assembly.LoadFrom("aaaaa.dll");
obj = asm.CreateInstance(ClassFullName);
Type t = asm.GetType(ClassFullName);
method = t.GetMethod("Run");
You can use reflection from your Blazor, but because your application runs in the browser you don't have access to the file system like you typically would in Web Forms app. So you can't just read an assembly off of the local file system, but you could, for example, retrieve the assembly from the server.
var bytes = await Http.GetByteArrayAsync("_framework/_bin/ClassLibrary1.dll");
var assembly = System.Reflection.Assembly.Load(bytes);
var t = assembly.GetType("ClassLibrary1.Class1");
var m = t.GetMethod("GetMessage");
Console.WriteLine($"ClassLibrary1.Class1.GetMessage(): {m.Invoke(null, null)}");
@danroth27 I understand that, thank you!
Most helpful comment
You can use reflection from your Blazor, but because your application runs in the browser you don't have access to the file system like you typically would in Web Forms app. So you can't just read an assembly off of the local file system, but you could, for example, retrieve the assembly from the server.