I have 2 DLLs, A.dll contains:
namespace Alphabet { public delegate void TestHandler(); public class A { private void DoTest() { Type type = Assembly.LoadFile("B.dll").GetType("Alphabet.B"); Object o = Activator.CreateInstance(type); string ret = type.InvokeMember("Hello", BindingFlags.InvokeMethod | BindingFlags.Default, null, o, null); } } }
and b.dll contains
namespace Alphabet { public class B { public event TestHandler Test(); public string Hello() { if (null != Test) Test(); return "Hello"; } } }
I use InvokeMember to get the result from B.dll, and I also want B.dll to be Test() before returning the result. So, how can I bind delegate to event in B.dll through reflection?
Any help would be appreciated!
source share