HighTechTalks DotNet Forums  

Getting at Service object from remoted object?

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss Getting at Service object from remoted object? in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Grant Schenck
 
Posts: n/a

Default Getting at Service object from remoted object? - 09-13-2006 , 08:41 AM






Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote
server and I can, via an IPC Channel, expose methods on an object and call
them from a
client. However, I now want my remoted object to be able to invoke a method
on my server object and given that the object is built in a C# Class DLL
shared between the client and server I'm not sure how to get access to the
server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,
--
Grant Schenck



Reply With Quote
  #2  
Old   
Grant Schenck
 
Posts: n/a

Default Re: Getting at Service object from remoted object? - 09-13-2006 , 09:17 AM






Hi,

See below.

Thanks, Grant Schenck

----- Original Message -----
From: "Nicholas Paldino [.NET/C# MVP]" <casperOne (AT) caspershouse (DOT) com>
To: <schenckg (AT) optonline (DOT) net>
Sent: Wednesday, September 13, 2006 8:41 AM
Subject: Re: Getting at Service object from remoted object?


Quote:
Grant,

The object you expose through remoting is an object, nothing more, nothing
less. To that end, you can expose properties, methods, fields,
etc, etc, that will allow it to access the server, assuming that your
object
has a reference to it.
[GRANT] Right, I need a reference to my Service object.

Quote:
So how does your object get access to the server? This is the same
as asking how a form has access to another form. You set a reference
through a method, the constructor, a field, or a property.
[GRANT] If I create a form from one form, I can pass the first form to the
second form. However, the remoting object isn't created until the client
invokes the remoted object method so I'm confused as to how the server could
get access to the object between when it is created and when the method is
invoked. Part of my confusion is I'm not clear how my remoted object, built
as a C# DLL class, can be able to call methods in my Service object.

Quote:
The only consideration here is that if you expose a property with
your service object through remoting, is it going to be marshaled by
value,
or by reference? Something tells me you will want it to be marshaled by
reference, in which case you will want to derive your server class from
MarshalByRefObject.
[GRANT] Are you saying I should derive my Service class from
MarshallByRefObject (as well as ServiceBase) and somehow this object would
be a singleton for all clients, i.e., my remoted object IS my service???

Quote:
Not seeing your service object design, I can't tell if it is a good
idea to expose the whole object. You might be exposing things you don't
want
to.
[GRANT] Actually I don't. My goals seem simple.

- I have a service running (controls a phone system but not particularly
relevent)
- I want to remote a single method (MakeCall)
- Client applications will invoke this method and pass a few parameters.
- Service will "get" these requests, presumably each on its own thread and
able to overlap, and via appropirate protection, service the request.
- Serving the request takes real time so using IPC (thanks from yesterday!)
the method blocks waiting for the async work to complete.
- At some point the work completes and the service will then release the
client method call thread and let it return the results.

So, I only want to expose one method from my server.

Quote:
Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp (AT) spam (DOT) guard.caspershouse.com

"Grant Schenck" <schenckg (AT) optonline (DOT) net> wrote in message
news:Oj6Ar5y1GHA.4484 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote

server and I can, via an IPC Channel, expose methods and call them
from a
client. However, I now want my remoted object to be able to invoke a
method on my server object and given that the object is built in a C#
Class DLL shared between the client and server I'm not sure how to get

access to the server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,
--
Grant Schenck







Reply With Quote
  #3  
Old   
James Westgate
 
Posts: n/a

Default Re: Getting at Service object from remoted object? - 09-13-2006 , 09:58 AM



You need to bear in mind that the client will be creating a reference to
a remote object, which it then references as if it were local.
I highly recommend a book by Ingo Rammer on .NET remoting which walks
through all of these scenarios and will allow you to choose the best
techniques for accessing objects remotely, and calling methods.

Best wishes
James

http://www.crainiate.net


Grant Schenck wrote:
Quote:
Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote
server and I can, via an IPC Channel, expose methods on an object and call
them from a
client. However, I now want my remoted object to be able to invoke a method
on my server object and given that the object is built in a C# Class DLL
shared between the client and server I'm not sure how to get access to the
server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,

Reply With Quote
  #4  
Old   
Spam Catcher
 
Posts: n/a

Default Re: Getting at Service object from remoted object? - 09-13-2006 , 03:08 PM



"Grant Schenck" <schenckg (AT) optonline (DOT) net> wrote in
news:#ziLcFz1GHA.1304 (AT) TK2MSFTNGP05 (DOT) phx.gbl:

Quote:
However, I now want my remoted object to be able to invoke a method
on my server object and given that the object is built in a C# Class
DLL shared between the client and server I'm not sure how to get
access to the server object from the remoted object.

RemotingService.Marshal(ObjectReference)

So RemoteService.Marshal(ME) <-- ME being the service class.


Reply With Quote
  #5  
Old   
ykozlov@pc-studio.com
 
Posts: n/a

Default Re: Getting at Service object from remoted object? - 09-28-2006 , 06:24 AM



Hi Grant,

all you really need is reference to server object within your remote object.

To this purpose you can, for example, define a static variable in your remote object' class which has a type of your server object (or, much better, of an interface to your server object). Than, in server object constructor, just assign 'this' to this static variable. Since remote objects are created within server, all newly created remote objects will automatically nave this variable set. Than your remote object can make calls to your server through this reference .

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.