Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form.ShowDialog in hidden application

Tags:

c#

winforms

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.

like image 756
aleshko Avatar asked Feb 23 '26 09:02

aleshko


2 Answers

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

See this link for reference.

like image 129
insomnium_ Avatar answered Feb 24 '26 22:02

insomnium_


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.

like image 44
Patrick Hofman Avatar answered Feb 25 '26 00:02

Patrick Hofman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!