dynamic PRoxy

  • Thread starter Thread starter Richard Cook
  • Start date Start date
Richard Cook said:
Is there anything equivalent to java.lang.reflect.Proxy?

I sent Richard this information, but it might be of interest to the
group.

There's nothing in .NET exactly like java.lang.reflect.Proxy, but
there are a couple of ways you might implement something like it.

First, you can create a class that uses Reflection.Emit to output the
desired proxy classes. This is probably the only way to implement
something like the Java Proxy class, but it involves developing an
intimate knowledge of MSIL.

Second, you can get something like java.lang.reflect.Proxy by
subclassing the ProxyAttribute and RealProxy classes, but there are a
couple of caveats:

- These classes are intended for use with .NET Remoting (although
there's no reason why you can't use them for other purposes)
- Unlike java.lang.reflect.Proxy, you can't simply supply the
interfaces you want the proxy to implement; you have to supply the
actual class you want proxied
- The class to be proxied has to inherit from
System.ContextBoundObject

The book "Microsoft .NET Remoting" (Microsoft Press) has some good
examples of how to use ProxyAttribute and RealProxy.

Wayne
____________________________________

Wayne Citrin
JNBridge, LLC
(e-mail address removed)
www.jnbridge.com
Spanning the Worlds of Java and .NET
____________________________________
 
Back
Top