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 / Component Services / January 2004

Tip: Looking for answers? Try searching our database.

Remoting from Windows Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee Gillie - 15 Jan 2004 22:52 GMT
Does someone have a design pattern for an singleton object, published
by a Windows Service, that can be used to provide control over the
service?

Things such as configuration parameters. It would be nice if the
remoted object instance in the could call functions in the service
class (set/get your config parameters, for example), but of course
that visibility is not there (the service is an EXE and can not be
brought in to project reference for the remoted class, which is in a
separate DLL).  I can see how the service might call methods on the
remoted object, but I can not see how to get activity to occur in the
service, which are based on some activity a client initiated through
method calls on the remote object.

Maybe there is a good sample you know of.

Best regards, Lee Gillie, Spokane, WA
Kevin P. Fleming - 15 Jan 2004 23:35 GMT
> Things such as configuration parameters. It would be nice if the
> remoted object instance in the could call functions in the service
[quoted text clipped - 5 lines]
> service, which are based on some activity a client initiated through
> method calls on the remote object.

There is an example recently posted to planetsourcecode that does
exactly this. In a nutshell, the service instantiates the object and
provides it to RemotingServices to be marshalled. This means the service
can keep a reference to it, allowing it to respond to events that the
object may raise, or allowing the object to call private methods on
types present in the service to perform functions on behalf of remote
callers.

The core of this type of implementation is that the type being remoted
(located in a shared DLL) is actually an abstract class; the
implementation of the remote object is done by creating a real class
inside the service that inherits from the abstract class and performs
the work.
DevGuy - 16 Jan 2004 03:07 GMT
I have implemented something very similar to this, but I have one problem
that I haven't quite solved.

My client(s) get a reference to the service-hosted remote object. But, I am
having a real problem figuring a (fast) way to determine when the service is
stopped (or the machine is rebooted, power fails, etc). of course, I will
eventually (after several seconds) trap the "The underlying connection was
closed: Unable to connect to the remote server" error, but is there any way
to do this more efficiently?

Any ideas would be most appreciated!

Thanks,
Joe

> > Things such as configuration parameters. It would be nice if the
> > remoted object instance in the could call functions in the service
[quoted text clipped - 19 lines]
> inside the service that inherits from the abstract class and performs
> the work.
Kevin P. Fleming - 16 Jan 2004 04:38 GMT
> My client(s) get a reference to the service-hosted remote object. But, I am
> having a real problem figuring a (fast) way to determine when the service is
> stopped (or the machine is rebooted, power fails, etc). of course, I will
> eventually (after several seconds) trap the "The underlying connection was
> closed: Unable to connect to the remote server" error, but is there any way
> to do this more efficiently?

I can't think of any better way, but I don't have a lot of experience at
this. However, both of the supplied channels use TCP as their underlying
mechanism, so theoretically when the service is shutdown gracefully the
open TCP socket will receive a "disconnect" from the server. Whether
that's visible at any higher layers and can be acted upon... no idea.

Most likely a third-party channel could provide a solution to this
problem (I've look at the GenuineChannels stuff and it looks nice, but
it's overkill for my application).
GeorgeG - 18 Jan 2004 19:58 GMT
Hi,

I recently did a similar project and I had the same problem, ie clients
could not know if the server is up with its remoted objects.
Unfortunatly I could not find anything on how to do it 'properly'. So I have
the clients trying to call a method on the server every few minites. If the
server is not up then tcp will throw an exception "host actively refused the
connection" which means no one is listening on the port on the server side.
Also after a method call the tcpchannel will be up only for a short "unused"
time. ie if you dont call your method frequent the tcpchannel will drop.

Note that if you have a callback object then u will see that the client is
creating a listener socket (remoting level) on the just failed method call
socket. Use tcpview to see this.. weird.. i had a case where the GC was not
collecting these objects..freaky stuff..

- George.

> > My client(s) get a reference to the service-hosted remote object. But, I am
> > having a real problem figuring a (fast) way to determine when the service is
[quoted text clipped - 12 lines]
> problem (I've look at the GenuineChannels stuff and it looks nice, but
> it's overkill for my application).

Rate this thread:







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.