HELP: expose Windows dialog from Windows Service

H

Hank

I am writing a windows service in C#.NET which will manage image capturing
devices, when client connects to the service, at some point the service need
to expose a device dialog to the client for setting some device specific
parameters. According to MSDN docs, classes within the Windows Forms
namespace are not supported for use within a Windows service. So How can I
do that?
Thanks!
 
G

Gerrit H

Hank,

You can't open a dialog from a service, since it is a background proces that
isn't permitted to have it so it can run at startup before anyone logs on.
What you could do is design an application that remains in the systemtray
which communicates with your service and does as you ask.

Question remains: is a windows service the best solution? A windows service
isn't supposed to have a user interface. Since it needs to ask the user for
options at some stage, does it really need to be started and running before
anyone logs on. How about multiple users on the same machine or no-one ever
logs on? What do you do than?

Gerrit H
 
A

almir

Hy Hank,

you have to show dialog on a client and not on a Service machine/side ,
as this two are different, as much as I know it is not possible to
wirte any GUI to use with service, so if you are sure you want to use
service for some reason (what are those?) you have to connect to it
over remoting infrastructure and talk to your service via remoting, and
show dialogs in user process, which is not service.

regards
almir
 
P

Phil Wilson

I'm not sure what you are describing when you say "client connects to the
service" but the thing that comes closest to dialogs from a Windows Service
is a tray icon (NotifyIcon class) with a context menu that pops up a dialog,
like some anti-virus products. It's not a good thing however because it
exposes security holes and I believe that the service is required to run
with the LocalSystem account. I think I've read something about Microsoft
removing the ability to do this from a service in a future OS because of the
security issues.
 
J

Jeffrey Tan[MSFT]

Hi Hank,

Does the community's replies make sense to you? If you have any concern
please feel free to tell me.

Yes, we'd better write our sevice as client/server structure, use
interprocess-communication to exchange information between client
application and server application. Then services can send a notification
to the client application to show out a dialog box for configuration. This
is what most server side applicaitons do, like SqlServer, etc..

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top