Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / December 2004

Tip: Looking for answers? Try searching our database.

Exposed Object vs Remoting server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
news.microsoft.com - 16 Dec 2004 17:26 GMT
Hello!
I have a remoting server which exposes a Singleton object to a client.
The client can call methods on the object without any problem.

Now, I'm trying to let the client modify the exposed object.
My question is: How would the server be able to load the exposed object
an retrieve the value set by the client? I'm asking because there is no
mention of the currently exposed instance of the class in the server code.

Or how do I expose a named instance of an abject to my clients? (having
a named instance would probably solve my problem)

Thanks
Ken Kolda - 16 Dec 2004 19:27 GMT
Allow the server to access the same object which is remoted to the clients
is a frequently occurring problem in remoting. Luckily, the answer is pretty
simple. Currently, you've probably registered your remoting object using
RemotingConfiguration.RegisterWellKnownServerObject(). The problem is that
this method exposes the object anonymously, i.e. the server doesn't have a
reference to this instance.

To fix this, you do two things:

1) Declare and instantiate a named instance of your remote object.
2) Get rid of your call to RegisterWellKnownServerObject() and instead call
RemotingServices.Marshal() on your named object. This will expose the object
so it can accept client requests.

Hope that helps -
Ken

> Hello!
> I have a remoting server which exposes a Singleton object to a client.
[quoted text clipped - 9 lines]
>
> Thanks
Rob Richardson - 16 Dec 2004 19:49 GMT
Ken,

Thanks for your reply.  I am a newbie in this area, and do not know about
named objects.  I haven't found a clear sample on the Web.  Could you point
me to a sample of this technique?

Thanks again!

Rob
Rob Richardson - 16 Dec 2004 21:08 GMT
Ken,

I tried using RemotingServices.Marshal() as you suggested.  It worked!

In the server, I replaced:
RemotingConfiguration.RegisterWellKnownServiceType (typeof (Clock), "Clock",
WellKnownObjectMode.SingleCall);
with:
Clock serverClock = new Clock();
serverClock.Number = 99;
ObjRef serverClockRef = RemotingServices.Marshal(serverClock,
"ServerClockURI");

In the client, I replaced:
RemotingConfiguration.RegisterWellKnownClientType (typeof (Clock),
"tcp://localhost:1234/Clock");
with:
RemotingConfiguration.RegisterWellKnownClientType (typeof (Clock),
"tcp://192.168.1.29:1234/ServerClockURI");

The client application happily reported that it was using clock number 99.

Next question:  For my application as it is currently designed, this will
suffice, since there will never be more than a single client communicating
with a server.  But what happens when we decide that a single server
application will manage an unknown number of printers?  In that case, I
would want my objects to be client-activated, but I still want the server to
know what objects it created.  How do I do that?

Thanks again!

Rob
Ken Kolda - 16 Dec 2004 21:50 GMT
In this case, you probably want to go with a factory model. In this model,
you create a singleton SAO which serves up your CAOs. By doing this you're
able to keep a hold of references to the same CAOs used by the clients. For
a good explanation of implementing a factory model in remoting, check out:

http://www.glacialcomponents.com/ArticleDetail/CAOGuide.aspx

Ken

> Ken,
>
[quoted text clipped - 28 lines]
>
> Rob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.