看我可能以错误的方式接近这个,方向是非常受欢迎的。
我正在尝试触发Start
我的解决方案中的所有方法。
Start 方法需要一个日期时间
但是,当尝试将日期作为“调用”的参数传递时,我遇到了错误
无法从 System.DateTime 转换为 object[]
欢迎任何想法
谢谢gws
scheduleDate = new DateTime(2010, 03, 11);
Type[] typelist = GetTypesInNamespace(Assembly.GetExecutingAssembly(), "AssetConsultants");
foreach (Type t in typelist)
{
var methodInfo = t.GetMethod("Start", new Type[] {typeof(DateTime)} );
if (methodInfo == null) // the method doesn't exist
{
// throw some exception
}
var o = Activator.CreateInstance(t);
methodInfo.Invoke(o, scheduleDate);
}