private void CallLaodAssembly()
{
string path = @"";
object[] param = { "1", "5" };
LoadDllMethod("Project1.Class1", "AddTwoNumbers", path, param);
}
static int LoadDllMethod(string title_class, string title_void, string path, object[] parameters)
{
int _result=0;
Assembly _assembly = Assembly.LoadFile(path);
Type _type = _assembly.GetType(title_class);
if (_type != null)
{
MethodInfo _MethodInfo = _type.GetMethod(title_void);
if (_MethodInfo != null)
{
if (parameters.Length >= 1)
{
object[] myparam = new object[1];
myparam[0] = parameters;
_result = (int)_MethodInfo.Invoke(null, myparam);
}
else
_result = (int)_MethodInfo.Invoke(null, null);
}
}
return _result;
}
No comments:
Post a Comment