all groups > dotnet remoting > july 2005 >
You're in the

dotnet remoting

group:

Custom proxy in interface-based approach


Custom proxy in interface-based approach Guillaume St-Pierre
7/28/2005 10:07:08 AM
dotnet remoting:
Apparently, using a custom proxy with an interface-referenced object
obtained from a server is impossible.

I have this scenario :

My server application registers a singleton SAO as the starting point for
all communication with clients. The client obtains this SAO with the common
Activator.GetObject, and then receives more objects from the server to work
with as it invokes methods. These objects can be considered
"client-activated". When the object is MBR, the server only returns
interfaces, for good design practices' sake. Therefore, there is no
well-known class between the two applications, only well-known interfaces.

Of course my real classes derive from ContextBoundObject, because I have to
do so, for reasons still obscure to me.

Now, digging through the examples at hand, I tried desperately to do
something said by many to be simple : create a RealProxy-derived class by
means of a ProxyAttribute-derived class and use it for all my
client-activated objects. Nowhere is it documented, or mentionned, that this
would not work in this particular case. I had to spend a lot of time
scratching my head, and looking through disassembled code to finally find
out why I get an exception stating "Could not load type ...".

Seems that the Unmarshal method wants to load my implementation class so it
can retrieve the proxy attribute it's using. But the client, of course,
doesn't have the type's assembly, it's using interfaces that are found in a
different assembly, the shared one.

Oh, what a powerful technique this is, custom proxies, but wait, you have to
give up another very useful feature of .NET, a basic concept! And we are not
going to tell you that. It's of no matter, anyways, who uses interfaces.
Find it out yourself if you're really so inclined, Captain Abstraction.

Now for the constructive part... I can hardly believe what I want to do is
theorically impossible. I am restricted by an incomplete design. I don't see
why the ProxyAttribute information could not be stored in the ObjRef, for
example. Or why it couldn't be applied to an interface. I mean, if this is
only a matter of finding the attribute, if this really is the only thing
restricting this scenario... I do not know, because I can't go any further.
I don't see why it cannot work though, because the framework's default
behavior has no problem using my interface with RemotingProxy. Therefore it
must be feasible.

All that being said, could anyone suggest something that does work ? I'm
still hoping that I've missed something trivial...

Thanks for any input you can provide.



Guillaume St-Pierre

Re: Custom proxy in interface-based approach Roy Chastain
7/28/2005 10:22:26 AM
I will admit that at this point I don't know why one would want to use a custom proxy, but I think that I you simply turn your
interfaces in abstract base classes, it might work. Rammer mentions that you can not use pass objects as an interface type
because MarshalBytRefObject cannot be downcast to the interface. There is no such restriction noted for abstract base classes.
You must of course use the Activator.GetObject or a factory to create an instance.

Good luck

[quoted text, click to view]

-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
Re: Custom proxy in interface-based approach Guillaume St-Pierre
8/1/2005 9:41:55 AM
I do not believe that abstract classes would work any better. Judging from
the code in RemotingServices class, it wants to load the complete type of my
implementation object to check its proxy attribute.

Rammer talks about using abstract classes instead of interfaces in the case
of a multiserver configuration, where one ObjRef must travel through
different hosts. Another limitation of the framework that could have been
avoided. He has lots of other examples where he's using interfaces.

Rammer also mentions "You might also just ship the server-side
implementation assembly to the client and reference it directly. But as I
stated previously, this is clearly against all distributed application
design principles!"

Still, thanks for your input, Roy. Sorry for ranting.


Guillaume


[quoted text, click to view]


Re: Custom proxy in interface-based approach Roy Chastain
8/1/2005 11:34:07 AM
Well, I have not looked at the code in the RemotingServices class, BUT I think I am doing what you described and I am using
abstract classes.

[quoted text, click to view]

-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
Re:Custom proxy in interface-based approach linux par
4/2/2006 6:04:35 AM
Configuring Internet Explorer to use proxy server has never been easier:

If you want to configure it from command line, look at:
http://ieproxycfg.50webs.com/index.html
and if you are looking for UI approch, look at:
http://ieproxycfg.50webs.com/proxychain.html

C'ya

AddThis Social Bookmark Button