在服务器中显示模式对话框时出错;当应用程序不在UserInteractive模式下运行时,显示模式对话框或窗体是无效操作.指定... [英] error while displaying modal dialog box in server ; Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the...

查看:94
本文介绍了在服务器中显示模式对话框时出错;当应用程序不在UserInteractive模式下运行时,显示模式对话框或窗体是无效操作.指定...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码

I am using the following code

static public class TopMostMessageBox
{
    static public DialogResult Show(string message)
    {
        return Show(message, string.Empty, MessageBoxButtons.OK);
    }
    static public DialogResult Show(string message, string title)
    {
        return Show(message, title, MessageBoxButtons.OK);
    }
    static public DialogResult Show(string message, string title, 
        MessageBoxButtons buttons)
    {
        // Create a host form that is a TopMost window which will be the 
        // parent of the MessageBox.
        Form topmostForm = new Form();
        // We do not want anyone to see this window so position it off the 
        // visible screen and make it as small as possible
        topmostForm.Size = new System.Drawing.Size(1, 1);
        topmostForm.StartPosition = FormStartPosition.Manual;
        System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
        topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10, 
            rect.Right + 10);
        topmostForm.Show();
        // Make this form the active form and make it TopMost
        topmostForm.Focus();
        topmostForm.BringToFront();
        topmostForm.TopMost = true;
        // Finally show the MessageBox with the form just created as its owner
        DialogResult result = MessageBox.Show(topmostForm, message, title, 
            buttons);
        topmostForm.Dispose(); // clean it up all the way
        return result;
    }
}


这在我的本地系统中有效,并且在使用sql server 2008和framework 3.5的Windows 2008(64Bit)服务器中进行部署后,将出现以下错误


this is working in my local system and after deploying in Windows 2008 (64Bit) server with sql server 2008 and framework 3.5 the following error is coming


当应用程序不在UserInteractive模式下运行时,显示模式对话框或窗体是无效操作.指定ServiceNotification或DefaultDesktopOnly样式以显示来自服务应用程序的通知.

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.

推荐答案

那么,为什么不遵循提供的说明呢?

指定ServiceNotification或DefaultDesktopOnly样式以显示来自服务应用程序的通知.

对于Windows服务,只需将其设置为与桌面交互即可.
So, why don''t you follow the instructions provided?

Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

In the case of a Windows service, just set it to interact with the desktop.


这篇关于在服务器中显示模式对话框时出错;当应用程序不在UserInteractive模式下运行时,显示模式对话框或窗体是无效操作.指定...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆