Recently looked at Windows service,
1. A post was found: http://blog.csdn.net/knight94/article/details/627298
2. At the end of the link http://www.cnblogs.com/Googler/archive/2013/07/23/3208354.html, there is a sentance:the "Inter Act with Desktop "option was not a supported by Microsoft in Windows Vista and newer. So use it wisely and redesign your app if there are a solid chance that your service can being installed on Vista or Server 20 08.
That's why: I installed a Windows service in Win7, the main feature of this Windows service is to start a Windows Form app. This error is always reported when the service is started:
This problem occurs if a program was not fully compatible with Windows. Please contact the program or device manufacturer (s) for more information. In the Interactive Services Detection dialog.
3. Windows Service Properties:
Log on---> Allow service to interact with desktop.
4. Debug Windows Service:
There is a-to-debug the Windows service:
1). Modify "Output type" to "Windows application" on the Serivce Project Property tab page.
2). In the Main (), to add the following code in Program.cs:
static void Main ()
{
if (environment.userinteractive)
{
string[] args = {"", ""};
Service service = New Service ();
Service. Start (args);
}
Else
{
servicebase[] ServicesToRun;
//more than One user Service may run within the same process. To add
// Another service to this process, change the following line to
//Create a second service object. For example,
//
ServicesToRun = New servicebase[] {new Service1 (), New MySecondUserService ()};
//
ServicesToRun = new Servicebase[] {new Service ()};
Servicebase.run (ServicesToRun);
}
}