How can I supress Delphi DataSnap error message dialogs?

夙愿已清 提交于 2019-12-07 05:46:41

问题


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;

回答1:


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,



来源:https://stackoverflow.com/questions/3316692/how-can-i-supress-delphi-datasnap-error-message-dialogs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!