By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

vb.NET Front-End/Windows Service Communication...

P: n/a
I have an application model which will consist of a front-end
configuration application, which needs to control the state of a
back-end vb.net windows service (which is the component that does all
the work). Think of this in the same manner as say microsoft management
console and the w3svc (inetinfo) service.

What should the standard communication protocol be between the
configuration app and the service in this model?

For example, If I'm using the configuration app, and I click a button to
tell the service to do some action, what means of communication should I
use. Obviously, with .net, COM is not the way to go. Writing an XML
file, and having the service poll for changes in the xml file seems
hokey. So, I guess I'm looking for the proper way to handle this.

Any info you can provide would be appreciated...

Thanks,
Brian

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Brian,
The easiest way to have a service accept a "command" to do something is to
override the ServiceBase.OnCustomCommand method and have it call the same
procedure your Timer.Elapsed event handler calls.

Then you can use ServiceController.ExecuteCommand to invoke this custom
command.

Note I would probably define an Enum of CustomCommands that my service
supported so its easier to keep track of them. A custom command for
OnCustomCommand is an integer between 128 & 256, which also means you can
have multiple custom commands defined.

Remember that ServiceController can control services on your local machine
as well as services on remote machines. Note you may need to configure the
various machines to allow remote control of services.

An alternative, more flexible method, which also entails more work, is to
enable your service for .NET Remoting. You could either make it a .NET
Remoting Server, in which case you call a method to have it perform some
action, or a .NET Remoting Client, and possible handle an "update data
event" on your server remoting object that says to update data...

Both of the custom commands & remoting with a service are discussed in
Matthew MacDonalds book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press.

Hope this helps
Jay
"Brian Patrick" <bp*********@hotmail.com> wrote in message
news:uq**************@TK2MSFTNGP15.phx.gbl...
I have an application model which will consist of a front-end
configuration application, which needs to control the state of a
back-end vb.net windows service (which is the component that does all
the work). Think of this in the same manner as say microsoft management
console and the w3svc (inetinfo) service.

What should the standard communication protocol be between the
configuration app and the service in this model?

For example, If I'm using the configuration app, and I click a button to
tell the service to do some action, what means of communication should I
use. Obviously, with .net, COM is not the way to go. Writing an XML
file, and having the service poll for changes in the xml file seems
hokey. So, I guess I'm looking for the proper way to handle this.

Any info you can provide would be appreciated...

Thanks,
Brian

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #2

P: n/a
Jay - thanks for the reply. I have a question for you...

If using your ExecuteCommand idea, how would I pass parameters to the
service from the front-end app? It sound's like you mean I could just tell
the service to run one of a possible 128 commands, but not be able to pass
data along. Let me know if I'm incorrect...

Thanks,
Brian

"Jay B. Harlow [MVP - Outlook]" wrote:
Brian,
The easiest way to have a service accept a "command" to do something is to
override the ServiceBase.OnCustomCommand method and have it call the same
procedure your Timer.Elapsed event handler calls.

Then you can use ServiceController.ExecuteCommand to invoke this custom
command.

Note I would probably define an Enum of CustomCommands that my service
supported so its easier to keep track of them. A custom command for
OnCustomCommand is an integer between 128 & 256, which also means you can
have multiple custom commands defined.

Remember that ServiceController can control services on your local machine
as well as services on remote machines. Note you may need to configure the
various machines to allow remote control of services.

An alternative, more flexible method, which also entails more work, is to
enable your service for .NET Remoting. You could either make it a .NET
Remoting Server, in which case you call a method to have it perform some
action, or a .NET Remoting Client, and possible handle an "update data
event" on your server remoting object that says to update data...

Both of the custom commands & remoting with a service are discussed in
Matthew MacDonalds book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press.

Hope this helps
Jay
"Brian Patrick" <bp*********@hotmail.com> wrote in message
news:uq**************@TK2MSFTNGP15.phx.gbl...
I have an application model which will consist of a front-end
configuration application, which needs to control the state of a
back-end vb.net windows service (which is the component that does all
the work). Think of this in the same manner as say microsoft management
console and the w3svc (inetinfo) service.

What should the standard communication protocol be between the
configuration app and the service in this model?

For example, If I'm using the configuration app, and I click a button to
tell the service to do some action, what means of communication should I
use. Obviously, with .net, COM is not the way to go. Writing an XML
file, and having the service poll for changes in the xml file seems
hokey. So, I guess I'm looking for the proper way to handle this.

Any info you can provide would be appreciated...

Thanks,
Brian

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 21 '05 #3

P: n/a
Brian,
You are correct ExecuteCommand only allows you to run one of a possible 128
commands, no parameters.

If you need parameters, I would recommend the .NET Remoting solution.

As an alternative, depending on the nature of the parameters, I would
consider writing them to the Service's app.config file, then stopping &
restarting the service. If your service only has a single service in it,
stopping it causes it to be unloaded from memory, restarting it should then
cause it to re-read its app.config. Of course if you service reads its
config from the registry or a different file, then you may not need to stop
& restart it.

Hope this helps
Jay

"bpatrick100" <bp*********@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
Jay - thanks for the reply. I have a question for you...

If using your ExecuteCommand idea, how would I pass parameters to the
service from the front-end app? It sound's like you mean I could just
tell
the service to run one of a possible 128 commands, but not be able to pass
data along. Let me know if I'm incorrect...

Thanks,
Brian

"Jay B. Harlow [MVP - Outlook]" wrote:
Brian,
The easiest way to have a service accept a "command" to do something is
to
override the ServiceBase.OnCustomCommand method and have it call the same
procedure your Timer.Elapsed event handler calls.

Then you can use ServiceController.ExecuteCommand to invoke this custom
command.

Note I would probably define an Enum of CustomCommands that my service
supported so its easier to keep track of them. A custom command for
OnCustomCommand is an integer between 128 & 256, which also means you
can
have multiple custom commands defined.

Remember that ServiceController can control services on your local
machine
as well as services on remote machines. Note you may need to configure
the
various machines to allow remote control of services.

An alternative, more flexible method, which also entails more work, is to
enable your service for .NET Remoting. You could either make it a .NET
Remoting Server, in which case you call a method to have it perform some
action, or a .NET Remoting Client, and possible handle an "update data
event" on your server remoting object that says to update data...

Both of the custom commands & remoting with a service are discussed in
Matthew MacDonalds book "Microsoft Visual Basic .NET Programmer's
Cookbook"
from MS Press.

Hope this helps
Jay
"Brian Patrick" <bp*********@hotmail.com> wrote in message
news:uq**************@TK2MSFTNGP15.phx.gbl...
>I have an application model which will consist of a front-end
> configuration application, which needs to control the state of a
> back-end vb.net windows service (which is the component that does all
> the work). Think of this in the same manner as say microsoft
> management
> console and the w3svc (inetinfo) service.
>
> What should the standard communication protocol be between the
> configuration app and the service in this model?
>
> For example, If I'm using the configuration app, and I click a button
> to
> tell the service to do some action, what means of communication should
> I
> use. Obviously, with .net, COM is not the way to go. Writing an XML
> file, and having the service poll for changes in the xml file seems
> hokey. So, I guess I'm looking for the proper way to handle this.
>
> Any info you can provide would be appreciated...
>
> Thanks,
> Brian
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!


Nov 21 '05 #4

P: n/a

"Brian Patrick" <bp*********@hotmail.com> wrote in message
news:uq**************@TK2MSFTNGP15.phx.gbl...
I have an application model which will consist of a front-end
configuration application, which needs to control the state of a
back-end vb.net windows service (which is the component that does all
the work). Think of this in the same manner as say microsoft management
console and the w3svc (inetinfo) service.

What should the standard communication protocol be between the
configuration app and the service in this model?


I've been planning on doing this myself and I was told that Remoting is the
way to go.
Nov 21 '05 #5

P: n/a
Thanks guys - I'll have to look into .net remoting then. Do you know of any
*working* sample projects that are downloadble from the web?

Thanks,
Brian

"Jeff Johnson [MVP:VB]" wrote:

"Brian Patrick" <bp*********@hotmail.com> wrote in message
news:uq**************@TK2MSFTNGP15.phx.gbl...
I have an application model which will consist of a front-end
configuration application, which needs to control the state of a
back-end vb.net windows service (which is the component that does all
the work). Think of this in the same manner as say microsoft management
console and the w3svc (inetinfo) service.

What should the standard communication protocol be between the
configuration app and the service in this model?


I've been planning on doing this myself and I was told that Remoting is the
way to go.

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.