Window service interface

  • Thread starter Thread starter Erik TL
  • Start date Start date
E

Erik TL

Hi

How does one return a varible, value, or object from a window service
in .net?

How do I expose the service methods?

A link, code, or anything is wellcome, because I'm going bonkers!

/Erik TL
 
You are going to have to be more specific.

A Windows Service is a process (.exe) that is run by the Service Control
Manager. You can not "return" a variable or object from a process
(whether it is a service, or a console application, or a winforms
application).

Where and what do you want to return the data to?
 
Well, I have a windows service, that I want to do a Interface to. It
has runtimevalues (shedules in a sealed class), that I need to access.
So I want to return, preferably, an object (arrylist) to the interface.
If that's impossible, then perhaps a string value ...

I can understand the need to isolate the service process as such, but I
have diffuculties understanding the trouble of making disconnected GUI
to check runtime data...

/Erik TL
 
Remoting is one way to do this (I have used remoting for the exact same setup
as yours). Remoting is a way of doing inter-process calls in .net. Try
doing a search for remoting on MSDN to get started.

Regards, Jakob.
 
Hi


I've done the return-string-chat mentioned in every example, but I'd
like to
know how i can expose an object from the service or, even better - a
method.


In essence I'd like to be able to return an arraylist from the service
and/or do a method call. If all else fails return a string from inside
the service to a client...

maybe I'm missing something here but I don't really understand
remotingobject (as compared to how you could use windows services
before).

How do i instatiate an object inside the service (as singleton) and use
it in both service and inteface?

/Erik
 
Hey Erik,

Remoting really does not have anything to do with Windows services but if
you want to call objects in your service process from another (UI) process
then remoting is the way to do it. Remoting is a bit like DCOM (in the "old"
days) only simpler. The remoting architecture supports singletons so it is
ideal for calling objects living within a service. It even lets you use
events so that the service can notify the UI of any changes (this is a bit
tricky though but it can be done).

Of course, there are other more simple ways of communicating between a
service and a corresponding user interface. E.g. you can let the service
create files in a well-known folder and then have the UI process read these
files (and the other way around) but you might run into synchronization
problems.

If you want I can try making a small sample project for you - in that case
just send me an e-mail.

Regards, Jakob.
 
Hi,

Sen you a mail, I hope you got it...and once again thanks for the offer
- I accept it humbly.

Kind Regards
/Erik TL
 
Hi Erik,

I got you e-mail and I have put together a small sample for you. I hope it
will get you started :-)

Regards, Jakob.
 
Back
Top