在public class Service1 : System.ServiceProcess.ServiceBase
发现MessageBox.show无法直接使用。不知道什么原因,请指教
又改用什么方法才能达到弹出窗口的目的呢?

解决方案 »

  1.   

    用javascript的window.open();
    来做!
    具体代码你网上找一下,好多的!
      

  2.   

    在windows服务应用程序里也能用javascript?
      

  3.   

    Process.Start("C:\你的窗体程序.EXE")
      

  4.   

    终于把这个问题解决了
    直接用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!