This is a must watch video regardless of whether you know you are interested in the topic or not. It is just very cool technology and Doug (also see doug here. Hey.... is that my blog he is pointing to? I am truly honored... and of course confused???) has explained it succinctly. (And such nice handwriting too. It clearly distinguishes Doug as the Einstein of the year.) The code is available here.
Now that I have told you how great Remoting and RealProxy is I would like to register my complaints:
-
 |  | | It should be a standard at Microsoft to never force inheritance!!! |
|  |  | Dang-it-Larry but would Microsoft please quite forcing me to derive from objects in order to get can do functionality. .NET and C# only provide single inheritance so don't make it no inheritance by forcing me to derive from MarshalByRefObject in order to gain remoting functionality. IT SHOULD BE A STANDARD AT MICROSOFT TO NEVER FORCE INHERITANCE!!! You can allow inheritance for the simplest implementation but provide a workaround via which I can get the same functionality via interface inheritance for example.
- Creating the ProxyFactory is OK but isn't there some way to override or configure new so that it calls the proxy factory automagically rather than manually calling ProxyFactory.GetProxy()? RemotingConfiguration.Configure() can do this so is there some way for me to do this and have ProxyFactory.GetProxy() called when new is used instead? Hmm.... perhaps it is time to do some decompiling.
One idea for using interception is to enable load balancing or fail-over. Imagine that a function call is made that the proxy intercepts. Next, the proxy checks that the requested server is indeed available but if not, it searches (perhaps via UDDI) for another provider of the service and instead forwards the call on to that service. Hey, how 'bout Microsoft providing this functionality too?
Another way I would really like to use this is for UI customization. Imagine that a you publish out your application with a WinForm but the customer doesn't like a particular placement of a control or, more common perhaps, the customer wants to add an additional field. No problem you say. When you code calls new (see my earlier request to configure new to call ProxyFactory.GetProxy) to instantiate your form and instead the proxy steps in and looks in the configuration file to see if there is an entry that a different derived form be created instead. Viola! The customization is made.
12:28:57 AM
|