c# - 隐藏应用程序中的 Form.ShowDialog

标签 c# winforms

我有一个以隐藏模式运行的应用程序。在新版本中,我需要更新数据库,这就是为什么我需要显示某种形式以从用户那里获取一些数据以进行更新的原因。我使用 Form.ShowDialog 方法但出现错误。据说是错误的

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

我想我需要以其他方式显示形式,但我不知道该怎么做。

当我运行它时它运行良好,我想我应该手动将其称为服务器。但是当另一个服务启动时 代码:

  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);

发生此错误。

最佳答案

我建议使用 Windows 气球通知,因为它们不是为了显示来自隐藏应用的消息。

参见 this link供引用。

关于c# - 隐藏应用程序中的 Form.ShowDialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21475141/

相关文章:

c# - Linq:对列表进行分组,对其进行排序并获得最高的 x 值?

c# - WinDbg:SOS.dll x86 4.0.30319.237 的副本

c# - 如何从服务器向客户端发送更新?

c# - 如何使用 StreamWriter 在单词之间留出空格

c# - 在 Windows 窗体设计器中绑定(bind)对象

c# - 如何计算 1 个特定类(class)的所有开放形式?

c# - 列表 <T> 与 IEnumerable<T>

c# - 等待在 selenium 和 c# 中完成下载文件

c# - 使用代码在 Visual Studio 调试控制台中更改颜色

asp.net-mvc - 排除 RDLC 中嵌入的默认字体呈现为 PDF