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 / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Windows Service & Remoting - HELP!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Webmills - 29 Aug 2006 11:32 GMT
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
UhihaJax - 29 Aug 2006 12:02 GMT
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.

> Hi
>
[quoted text clipped - 18 lines]
>
> James
Webmills - 29 Aug 2006 14:08 GMT
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
Peter Bromberg [C# MVP] - 29 Aug 2006 15:38 GMT
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

Signature

Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

> Thanks for the speedy response.
>
[quoted text clipped - 7 lines]
>
> James
Webmills - 29 Aug 2006 17:15 GMT
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.
Peter Bromberg [C# MVP] - 30 Aug 2006 19:27 GMT
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

Signature

Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

> 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
[quoted text clipped - 16 lines]
>
> Thanks for your advice.

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.