c# - Hooking events by RealProxy -


i'm trying hook event (action in case) cant return proxy without exception. here's idea: have interface of events, not subscribed on client side. when try raise event on client side, catch event in proxy , send remote server name of event , parameters , wanna return proxy. here sample

public interface imyevents {     action onping { get; set; } }  public class proxy : realproxy {     type type;      public proxy(type type)         : base(type)     {         this.type = type;     }      public override imessage invoke(imessage msg)     {         var call = (imethodcallmessage)msg;         string methodname = (string)msg.properties["__methodname"];         object[] parameters = (object[])msg.properties["__args"];          // send command server         // senddata(methodname, parameters);          // tell invoker everything's fine         return new returnmessage(null, null, 0, call.logicalcallcontext, call);     } }  public class test {     public test()     {         proxy proxy = new proxy(typeof(imyevents));         events = (imyevents)proxy.gettransparentproxy();     }      public readonly imyevents events; }  class program {     public static void main(string[] args)     {         test t = new test();         t.events.onping();  // nullreferenceexception     } } 


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -