3

I have an application which runs in hidden mode. In new version I need to update database that is why I need to show some form to get some data from user for update. I use Form.ShowDialog method but errors occurred. It is said in error that

"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".

I guess that I need to show form in other way but I don't know how.

It works fine when i run this, i guess i should call it server, manually. But when another service starts it code:

  System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(path);
  startInfo.WorkingDirectory = ServerModel.ServerInfo.ServerDir;
  startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  System.Diagnostics.Process.Start(startInfo);

This error occurs.

5
  • Your code is calling or attempting to show a dialog from somewhere (middle tier, server, web service, windows service etc) where it cannot display that dialog or probably doesn't know what Windows Forms are for that matter. Commented Jan 31, 2014 at 8:09
  • I edit my question to clarify. Commented Jan 31, 2014 at 8:18
  • 1
    What exactly do you mean by "hidden mode"? Commented Jan 31, 2014 at 8:21
  • If you cannot show a dialog, why would you be able to show any UI? Commented Jan 31, 2014 at 8:23
  • I mean startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; Commented Jan 31, 2014 at 8:32

2 Answers 2

2

I would suggest to use windows balloon notifications, as they are mean't for showing messages from hidden apps.

See this link for reference.

Sign up to request clarification or add additional context in comments.

2 Comments

If ShowDialog() fails, so will balloon notifications
By "hidden" you mean "minimized to tray". OP's "hidden" app is running as a Windows Service app.
1

As the error message says you have to set the options of MessageBox.Show to either ServiceNotification or DefaultDesktopOnly. This applies to a MessageBox you probably try to show in your application.

5 Comments

I try to display not a messagebox but my defined winform.
But I guess you are trying to show a MessageBox inside there. That is the error you get. But probably, as the other answer said, you want to rethink your application design.
Any luck in find a solution?
Actually i think the problem was in other thing. The special service start this server and that mean that windows don't know whom it should show ui.Actually when i delete startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; line, even the descriptor of main window hadn't been create.That is why we remake the procedure of update.
Okay, but it is possible to post messages or windows to the default desktop by using one of the options I described above. The service needs to have the Allow service to interact with desktop option checked.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.