有两个 Assembly A,B 在A中声明了一个事件(某个类中的某个事件), B没有引用这Assembly ,但是想挂A中的这个事件。当A中的某个逻辑fire这个Event时,B挂事件的地方要(B的handler)要做些事情。
FireFarEvent 是 Assembly A,MainForm 类公开一个 SomeEvent 事件, FireEvent button 会 Fire 这个 Event.
AttachFarEvent 是 Assembly B,AttachFarEventForm 中 btnAttachEvent_Click 会 hook FireFarEvent 中的 SomeEvent.
AttachFarEvent代码如下: