即使一切看起來非常正確,我也得到一個調用Type.GetMethod()的函數的AmbigiousMatchException。C#動態函數AmbigiousMatchException?
public partial class IBaseEvent
{
private Dictionary<int, Func<object[], object>> funcs = new Dictionary<int,Func<object[],object>>();
private Dictionary<int, object[]> func_args = new Dictionary<int,object[]>();
public void Execute()
{
int exp = 0;
foreach(var func in funcs)
{
exp = func.GetHashCode();
func.Value.DynamicInvoke(func_args[exp]);
}
}
public void AddFunction(Type T, dynamic sFunc, params object[] parameters)
{
funcs.Add(T.GetHashCode(), new Func<object[],object>(T.GetMethod(sFunc)));
func_args.Add(T.GetHashCode(), parameters);
}
}
public class DummyEvent : IBaseEvent
{
private string EventType = "DUMMY_EVENT";
public DummyEvent()
{
object[] parm = new object[3];
parm[0] = Logging.LOG_TYPE.DEBUG;
parm[1] = "Hello World from DummyEvent! TypeCode: {0}";
parm[2] = typeof(DummyEvent).GetType().GUID;
AddFunction(typeof(Logging.LoggingFactory), "WriteToLog", parm);
}
}
AddFunction上的錯誤(typeof(Logging.LoggingFactory),「WriteToLog」,parm);
我在做什麼錯?我該如何糾正這一點?
你能分享你的'Logging'類? –