Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 21st, 2006, 07:27 AM
Registered User
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to steven43126
Default 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,
this, "EventCalled");
aEvent.AddEventHandler(this, myDel);

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!

Similar Threads
Thread Thread Starter Forum Replies Last Post
remote connection object in asp.net nirmalbarsainyan ASP.NET 2.0 Basics 1 August 9th, 2007 06:27 PM
Registering ASCX gbrown ASP.NET 1.0 and 1.1 Professional 1 January 9th, 2007 11:57 AM
How to call a method on a remote object eloyitomio C# 1 July 21st, 2006 10:17 AM
object parameters to remote method calls DotNetJunk General .NET 1 April 29th, 2005 04:02 AM
Registering DLL's askenkray Classic ASP Components 4 January 27th, 2005 03:05 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.