Registering events dynaically with a remote object
Ok where do i begin...
well i am trying to come up with a solution to allow me to register event handlers with an event dynamically. Consider the following code
if (aEvent.Name.CompareTo("getFilesCalledEvent") == 0)
Delegate myDel =Delegate.CreateDelegate(aEvent.EventHandlerType,
As far as im concerned this should register the method EventCalled contained in the running instance of the object pointed to by (this).
When executed i get the exception "Object does not match target type", when i call the AddEventHandler Method.
As far as i can assume this is because im using remoting, see aEvent is actually an EventInfo type returned from a remote object. So im guessing the delegate im passing in is actually trying to point to a local instance. But im registering it with a remote object, so when it tries to call back to the class that holds EventCalled it does not know to go through the remoting framework? Ie The object is pointing to does not exist in the context of the remote object.
This is my best guess anyone who can help your a godsend!