using System.Reflection;
class SampleProgram
{
public static void Main(String[] args)
{
Assembly extAssemblyFile = Assembly.Load(new AssemblyName("ExtAssembly"));
Type curType;
object currentAssembly;
foreach (Type type in extAssemblyFile.GetTypes())
{
if (type.IsClass)
{
currentAssembly = extAssemblyFile.CreateInstance(type.FullName);
curType = type;
}
}
Type ExtAssemblyType = ExtAssemblyFile.GetType("ExtAssembly.SampleClass");
ExtAssembly = Activator.CreateInstance(ExtAssemblyType);
String str = (string)curType.InvokeMember("JustMethod"
,BindingFlags.Default | BindingFlags.InvokeMethod
,null
,ExtAssembly
,new object[] { });
Console.WriteLine(str);
object[] parameter = new object[] { "строка" };
str = (string)curType.InvokeMember("ParMethod"
,BindingFlags.Default | BindingFlags.InvokeMethod
,null
,ExtAssembly
,parameter);
Console.WriteLine(str);
String str = (string)curType.InvokeMember("StaticMethod"
,BindingFlags.Default | BindingFlags.InvokeMethod
,null
,null
,new object[] { });
Console.WriteLine(str);
}
}