Windows Service & Remoting - HELP!!!

  • Thread starter Thread starter Webmills
  • Start date Start date
W

Webmills

Hi

I have created a Windows Service that keeps track of files and folders.
When files are added, deleted or updated, it maintains an internal list
of files.

I would like to access this information from a external program. I have
decided to use Windows Remoting.

I have added the remoting server information within the OnStart method
of the Windows Service. The TCP Channel is registered and the
WellKnownServiceType of my remoting object is registered.

However, this does not solve my problem. I cannot see any way that my
remoting object can access the Windows Service in order to access the
file information.

Am I missing something obvious?

Your help and advice would be most appreciated.

James
 
The remoting element needs to be part of the windows service for it to
properly broadcast the internal data.
e.g.

Hashtable myServiceData;

private void DoServicyStuff()
{
// do stuff with service data
}

public Hashtable GetServiceDataFromRemoting()
{
return myServiceData;
}

or the applications have to use a common datastore, such as a database or a
textfile.
Does that help? I apologise if I mis-understood the question.
 
Thanks for the speedy response.

Apologies, but I'm not certain that I understand your reply.

My web service contains an object that exists for the lifetime of the
web service. This object monitors the files and folders.

I would like it such that my remote objects (singleton or singlecall)
can access this object. This may or may not be possible.

James
 
In your first post, you said "Windows Service" and in the last, "WebService".
Which is it? If your service exposes a TCP Channel remoting server, then all
clients would need to do is connect to it as a Remoting client. They can use
a remotable class as a communication proxy provided it derives from
MarshalByRefObject.

Peter
 
Apologies for the error. In fact I am connecting to the Windows Service
from a Web Service, hence my mistake. It should have read Windows
Service. And it's been a long day :-)

I have now attacked this as below....

1) I have created an object inherited from MarshalByRefObject.
2) I have overridden its InitializeLifetimeService method to return
null.
3) In the On Start method of my Windows Service I have registered this
as a remote object using the RemotingServices.Marshal method.

I am hoping that I will now be able to access this from my web service
or external client. I am also hoping that it will persist for the
duration of the service.

Am I correct in this? Are there any major pitfalls of which I should be
aware.

Thanks for your advice.
 
Sounds like you have got it right to me. As long as your object has the
required methods, you should be able to call them from the client that
references this object which has been instantiated via remoting configuration.

I don't know of any major pitfalls.
Peter
 
Back
Top