Click here to Skip to main content
15,908,020 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have developed a windows service and i included System.Windows.Forms in windows service and i used one message box. It displays the message box while debugging the application in Visual Studio 2012. I installed the windows service through installutil.exe. But once after installation, the service is not getting started. It shows error message like the service cannot be started on local computer because the service may not be in use. When i clicked the log messages in Server manager i got the following error message Service cannot be started.
System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) at System.Windows.Forms.MessageBox.Show(String text)

Any one please help me to resolve this issue.
Thanks in advance
Posted

Simple. Remove the message box.

Win service is not UI and has no need for user communication. Therefore, your call to message box is illegal. Either put some logging into the service or create a service AND windows forms project that will use it...then you can show message box depending on the service result.
 
Share this answer
 
This[^] might help getting you in right direction.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900