Reputation: 22857
I have the following using System;
namespace mtSpec
{
public class SpecElement
{
public SpecElement (Delegate action, string name)
{
Name = name;
this.ActionToTake = action;
}
public Delegate ActionToTake {get; set;}
public string Name {get; set; }
public bool Execute()
{
try {
this.ActionToTake.DynamicInvoke();
return true;
} catch (Exception ex) {
return false;
}
}
}
}
Calling Execute always causes the following at the point of DynamicInvoke():
- Assertion: should not be reached at ../../../../mono/mini/debugger-agent.c:3092
Am I missing something? How can I invoke my delegate please?
Escoz? Miguel? Anyone?
Upvotes: 1
Views: 271
Reputation: 2033
Instead of Delegate I would use Action. No need to call DynamicInvoke.
public class SpecElement
{
public SpecElement (Action action, string name)
{
Name = name;
this.ActionToTake = action;
}
public Action ActionToTake {get; set;}
public string Name {get; set; }
public bool Execute()
{
try
{
this.ActionToTake();
return true;
}
catch (Exception)
{
return false;
}
}
}
Upvotes: 2