473,218 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

Windows Service access to variables/properties By Client Applicati

How do I access Public variables within a Windows Service?

I can, and have, created installed and executed a basic Service. From my
client App I can Start, Stop...etc the service.... What I want to do is to
read properties that are in the service. for instance if the service had a
Propertie or Public variable like

Public Int Myint = 12; (or... Public Myint as integer = 12)
Then how could I read that variable from a typical windows Form application?

The basic Idea is to have a service churning away all the time and then when
a client app OR mulitple client apps need info that the service is
calculating then the client app should be able to simple reference the
variable and read it .... no?


Jul 22 '05 #1
2 2271
On Thu, 14 Jul 2005 17:08:01 -0700, Dennis Stew wrote:
How do I access Public variables within a Windows Service?

Public Int Myint = 12; (or... Public Myint as integer = 12) Then how could I read that variable from a typical windows Form application?
You can't. A windows service is almost just a normal application except
that it runs in the background and has no UI. You can't access variables
from another application just like that. That would be too easy :-)
The basic Idea is to have a service churning away all the time and then when
a client app OR mulitple client apps need info that the service is
calculating then the client app should be able to simple reference the
variable and read it .... no?


No. An easy enough solution (among others) would be to expose an object
from your Windows Service through .NET Remoting. Your client applications
would then just need to connect to your .NET Remoting server and call
methods of the exposed object. These methods can return whatever values
they want. You effectively end up with a Client/Server system. Have a look
on the Web for .NET Remoting, there are loads of articles and tutorials to
do just what you want. Or get the excellent Ingo Rammer's book: Advanced
..NET Remoting.

Other than that, you could build a similar system but using raw sockets
instead of .NET Remoting (although i don't really see why you would want to
do that), use shared memory (that will require you to use the Win32 API
through interop since there are no .NET wrappers for this yet), have your
service write a file and your client applications read this file...
Jul 22 '05 #2
That would be crossing the app domain at run-time.
I believe you can do this but it isn't recommended and
can be a bit complex to implement reliably.

I think what a lot of people do is have the service
listen on a TCP socket. Your client apps would
open the socket, send a message, the service responds
back on the socket.

This should prove useful:

http://www.eggheadcafe.com/articles/20020323.asp

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net

Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp

"Dennis Stew" <Dennis St**@discussions.microsoft.com> wrote in message
news:F2**********************************@microsof t.com...
How do I access Public variables within a Windows Service?

I can, and have, created installed and executed a basic Service. From my
client App I can Start, Stop...etc the service.... What I want to do is to
read properties that are in the service. for instance if the service had
a
Propertie or Public variable like

Public Int Myint = 12; (or... Public Myint as integer = 12)
Then how could I read that variable from a typical windows Form
application?

The basic Idea is to have a service churning away all the time and then
when
a client app OR mulitple client apps need info that the service is
calculating then the client app should be able to simple reference the
variable and read it .... no?

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
I created an extremely simple windows service that only writes to the EventLogs on Stop and Pause. I installed it using the InstallUtil.exe program, the output of which is below. It appears to be...
6
by: Bijesh | last post by:
Hi All, I've developed a Windows Service that acts as a remoting server (.NET Remoting). The client(user) is able to connect to the server and start a program by giving the executable path of...
5
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the...
7
by: lvpaul | last post by:
Hallo ! I am using IIS-Windows-Authentication in my intranet (web.config <authentication mode="Windows" /> <identity impersonate="true" /> How can I get the users (client) IP-Address ? I...
1
by: MAL | last post by:
Hello, I have 2 classes that work great as a windows app to retrieve and process data from an Oracle9i db. When I implement them in a Service program running as Local System, it fails on the...
3
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim...
2
by: Dennis Stew | last post by:
How do I access Public variables within a Windows Service? I can, and have, created installed and executed a basic Service. From my client App I can Start, Stop...etc the service.... What I want...
6
by: Jimmy | last post by:
Hi, I need to develop a secure Web Service that requires a username and password. One of the requirements is that the WS supports Windows Authentication, meaning accepts the username and...
7
by: HeatherS | last post by:
We are having issues with our windows services using memory and never releasing it. We have one service that has a file watcher which takes an xml file, inserts some records into a database, and...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.