473,378 Members | 1,439 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,378 software developers and data experts.

Opening form from a windows service

Is it possible to attach a form (C# .NET 2) to windows service and show
it in OnStart event? When I tried to do this in general (new, Show())
way it just didn't do anything nor gave me any errors. I want to use
this form for interaction with the service.
Thanks!
Vit Zayko
Jan 13 '06 #1
3 14326
Vitaly Zayko wrote:
Is it possible to attach a form (C# .NET 2) to windows service and show
it in OnStart event? When I tried to do this in general (new, Show())
way it just didn't do anything nor gave me any errors. I want to use
this form for interaction with the service.


You may be able to do it if you change the service to allow interaction
with the desktop - but it's a really bad idea. Services aren't meant to
work like that - they're meant to be entirely in the background.

Instead, your service should expose some kind of control API, probably
over network sockets (eg exposing a remoting service). You could then
write a *separate* Windows Forms app to control it.

Jon

Jan 13 '06 #2
Thanks Jon! Probably I have to do as you said. I was thinking that the
way of direct form using will be easier.
Jan 13 '06 #3

"Vitaly Zayko" <vitaly_at_zayko_dot_net> wrote in message
news:Om**************@TK2MSFTNGP11.phx.gbl...
| Is it possible to attach a form (C# .NET 2) to windows service and show
| it in OnStart event? When I tried to do this in general (new, Show())
| way it just didn't do anything nor gave me any errors. I want to use
| this form for interaction with the service.
| Thanks!
| Vit Zayko

If you feel the need to show something to a user, you first have to ask
yourself if you really need a windows service. Most of the time the answer
is NO.
1. Services are meant to run in the background even when no interactive user
is logged on, they don't have access to the users desktop and they run in a
restricted users security context, so you shouldn't use any UI elements like
Forms in your service.
2. Your OnStart handler should return within 30 seconds, failed to do so
will flag your service as failed to start.

If you want some kind of user interaction with a service you need a second
windows application that uses one of the many IPC mechanisms available in
..NET or windows. The type of IPC you have to select highly depends on the
level of interaction you need, the most appropriate for bi-directional
exchange in .NET is remoting, if you are using v2.0 you can use the
namedpipe remoting channel. If the exchange is uni-directional (eg. service
status, performance info), you may take a look at System.Management
eventing.

Willy.
Jan 13 '06 #4

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

Similar topics

2
by: Eric Caron | last post by:
Hi Here's my problem, I create a windows service with Config.xml file. All setup for my service is in this file. I create a windows application to manage these settings (Config.XML File). This...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
3
by: tomyboy | last post by:
Read this from Dev Ashish http://www.mvps.org/accessfr/forms/frm0034.htm for opening a form in an other db This seems useful for my job I've a db named INVOICING making invoice and a 2nd db name...
1
by: Ian | last post by:
I want to open a form at a particular record, but I think I'm running into problems because the recordsource query is executing asynchronously. In the form's open event I use...
2
by: John | last post by:
Hi My app is in vb.net but the backend db is access. I am posting my question here as there is more access expertise here than in vb.net group. Here is the problem; I am opening a connection...
11
by: Andrew Mueller | last post by:
Hello, Is there any way to make a form part of a windows service application and launch it upon double-click of a system tray icon? I already have the NotifyIcon working and have added an...
6
by: Dean R. Henderson | last post by:
I have a DTS Package I am able to execute successfully from a Windows Form application, but I cannot get this to work from an ASP.NET Web Service, although the Web Service impersonates the same...
0
by: andyedw | last post by:
I have created a windows service in .net and a form to control and monitor the service which I would like to open onStart event of the service. I have tried allowing the service access to the...
0
by: pintu | last post by:
Hello friends, i am creating an application using .net 2.0 and c#..My requirement is to open a form which will take inputs from user to update one table through web service..But my problem is that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.