If you have already coped with the task of loading a DLL into memory, then the matter will remain small. Suppose the code example you give is:
WebClient webClient = new WebClient(); byte[] assemblyBytes = webClient.DownloadData("https://mysite.com"); var assembly = Assembly.Load(assemblyBytes);
And as a result of the execution of this code, we got an assembly into the assembly variable. Now, based on the knowledge of the type name and the method being called, you can get the type and call the method from it as follows:
// ΠΏΠΎΠ»ΡΡΠΈΠΌ ΡΠΈΠΏ (ΠΌΡ Π·Π½Π°Π΅ΠΌ Π΅Π³ΠΎ ΠΈΠΌΡ - myClass) Type type = assembly.GetType("myClass"); // ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ ΠΎΠ±ΡΠ΅ΠΊΡΠ° Π·Π°Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΡΠΈΠΏΠ° var obj = Activator.CreateInstance(type); // Π²ΡΠ·ΠΎΠ²Π΅ΠΌ ΠΌΠ΅ΡΠΎΠ΄ ΠΈΠ· ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΠΎΠ³ΠΎ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° Ρ Π·Π°Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΡΠΈΠΏΠ° type.InvokeMember( "GetSum", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, obj, new Object[] {5} );
For everything to work successfully, you need to take into account some of the nuances. The type myClass either should not have any constructors at all, so that the non-parametric constructor by default created the CLR for us, or there should be one non-parametric constructor so that Activator.CreateInstance can instantiate the object. Also, the type names must be correct, if there is a mismatch there will be an error. The last parameter of the Type.InvokeMember method is an array with arguments passed to the called member (method).