如何抑制 Delphi DataSnap 错误消息对话框?

发布于 2024-09-11 06:15:54 字数 599 浏览 1 评论 0原文

我们在 Windows 2003 Server 上运行 DataSnap Delphi 2009 应用程序。 DataSnap 客户端和服务器位于同一台计算机上,通过 Borland Socketserver 使用 DCOM。客户端运行后台批处理作业。

有时,我们发现客户端无法连接到服务器应用程序,并在服务器桌面上显示消息对话框,例如“无法连接到服务器。找不到网络路径”。或“未找到对象导出器”。

我们的 Delphi 客户端代码从不使用消息对话框来显示错误或异常,而是使用 try ... except .. finally ... end 和日志记录来处理连接错误,所以我猜该对话框是由 DataSnap 方法创建的。有没有办法抑制这个模式对话框?

更新:所有异常都在较低级别的例程中处理,主循环负责在引发异常(已处理或未处理)时断开连接和重新连接:

  while True do
  begin
    Connect;
    while True do
    begin
      try
        DoMyWork;
      except
        Break;
      end;
    end;
    Disconnect;
  end;

We run a DataSnap Delphi 2009 application on Windows 2003 Server. DataSnap Client and Server are on the same computer, using DCOM over Borland Socketserver. The client runs a background batch job.

Sometimes, we discover that the client can not connect to the server application and displays a message dialog on the server desktop indicating for example "Could not connect to server. Network path could not be found." or "Objectexporter not found."

Our Delphi client code never uses a message dialog to show errors or exceptions, instead we use try ... except .. finally ... end and logging to handle connect errors, so I guess the dialog is created by a DataSnap method. Is there a way to suppress this modal dialog box?

Update: all exceptions are handled in lower level routines, the main loop takes care of disconnecting and reconnecting when an exception is raised (handled or unhandled):

  while True do
  begin
    Connect;
    while True do
    begin
      try
        DoMyWork;
      except
        Break;
      end;
    end;
    Disconnect;
  end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人哭 2024-09-18 06:15:56

解决方案1)
也许 application.oneException 上的全局钩子可以解决问题

http://www.chami .com/tips/delphi/011497D.html

解决方案 2)

使用 EurekaLog 或 MadExcept 找出应用程序引发错误的位置,并处理该错误。

解决方案 3)

应用程序消息对话框上的全局挂钩,挂钩示例如下

http://delphi.about.com/gi/o.htm?zi=1/XJ&zTi=1&sdn=delphi&cdn=计算&tm=43&f=22&su=p284.9.336.ip_p504.1.336.ip_&tt=2&bt=1&bts=1&zu=http%3A//www.delphicorner.f9.co.uk /articles/apps7.htm

您查询应用程序的所有消息,当您捕获该窗口时,您将处理消息而不是应用程序。因为我现在没有时间,我不知道到底哪个是 messagedlg 引发的 wmessage。

希望有帮助。

此致,

solution 1)
maybe an global hook over the application.onexception can handle the problem

http://www.chami.com/tips/delphi/011497D.html

solution 2)

use EurekaLog or MadExcept in order to find out from where the application raise that error, and handle the error.

solution 3)

a global hook over the application message dialogs, a hook example is bellow

http://delphi.about.com/gi/o.htm?zi=1/XJ&zTi=1&sdn=delphi&cdn=compute&tm=43&f=22&su=p284.9.336.ip_p504.1.336.ip_&tt=2&bt=1&bts=1&zu=http%3A//www.delphicorner.f9.co.uk/articles/apps7.htm

you query all the application's messages, and when you catch that window then you process the message not the application. because i don't have now the time I don't know exactly which is the wmessage raised by messagedlg.

hope that helped.

best regards,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文