终于把这个问题解决了 直接用MessageBox.Show("message");的话会出现“System.InvalidOperationException: It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.”这样的异常 只要在MessageBox.Show方法中将MessageBoxOptions 枚举取值ServiceNotification就可以了 代码如下: MessageBoxButtons buttons = MessageBoxButtons.YesNo; MessageBox.Show("message", "caption",buttons,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification);感谢楼上两位的帮助 还要特别感谢luxel!
来做!
具体代码你网上找一下,好多的!
直接用MessageBox.Show("message");的话会出现“System.InvalidOperationException: It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.”这样的异常
只要在MessageBox.Show方法中将MessageBoxOptions 枚举取值ServiceNotification就可以了
代码如下:
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
MessageBox.Show("message", "caption",buttons,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification);感谢楼上两位的帮助
还要特别感谢luxel!