views:

162

answers:

1

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;
+3  A: 

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,

Radu Barbu
The application uses madExcept and exception logging, it looks like no exception is thrown when the error message box appears
mjustin