Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Algorithmen, Datenstrukturen und Klassendesign (https://www.delphipraxis.net/78-algorithmen-datenstrukturen-und-klassendesign/)
-   -   Stringlist bringt Service zum Absturz (https://www.delphipraxis.net/160261-stringlist-bringt-service-zum-absturz.html)

himitsu 5. Mai 2011 14:40

AW: Stringlist bringt Service zum Absturz
 
Stimmt, SvcMgr.Application (TServiceApplication) hat kein OnException,
aber SvcMgr läßt die unit Forms.
Forms.Application hat ein OnException.

Aber jetzt fällt mir da wieder was ein.

Leider ist TServiceApplication so schrottig programmiert, daß man da nicht mehr an die Exceptionbehandlung rankommt, ohne die von TServiceApplication zu schrotten.
(es sei denn man möchte das Logging in den Windows-Event-Logs (MSDN-Library durchsuchenReportEvent) umgehen)

Wenn du TService (SvcMgr) verwendest, dann füge mal Folgendes in deine Service-Anwendung (DPR) ein.
Delphi-Quellcode:
uses SysUtils, Classes, SvcMgr, ...;

{$R *.RES}

type
  TServiceApplicationHack = class(TServiceApplication)
  protected
    procedure DoHandleException(E: Exception); override;
  end;

procedure TServiceApplicationHack.DoHandleException(E: Exception);
begin
  // hier kannst du E.Message irgendwo hin loggen
  inherited;
end;

begin
  Application.Free;
  Application := TServiceApplicationHack.Create(nil);
  ...
Und ja, Application wird am ende nicht wieder freigegeben ... das macht die Unit SvcMgr für uns.


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:16 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz