I have following exception
An unhandled exception of type 'System.ArgumentException' occurred in WindowsBase.dll
Additional information: 'Event' event not found on type 'ConsoleApplication.ITest'.
in this repro:
using System.Windows; // add reference to WindowsBase
interface IBase
{
event EventHandler Event;
}
interface ITest : IBase { }
class Test : ITest
{
public event EventHandler Event;
}
class Program
{
static void Main(string[] args)
{
var test = new Test();
WeakEventManager<IBase, EventArgs>.AddHandler(test, "Event", (s, e) => { }); // works
WeakEventManager<ITest, EventArgs>.AddHandler(test, "Event", (s, e) => { }); // exception
}
}
Why inherited via interfaces event can't be found? Exception is thrown from this method.
I've tried various combinations about your example. Here comes the only working code down here. It seems you need to know where the event is defined specificaly in the inheritance hierarchy.
Whole combinations so far ;