AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Fehler: Ein ausgehender Aufruf kann nicht ausgeführt werden...
Thema durchsuchen
Ansicht
Themen-Optionen

Fehler: Ein ausgehender Aufruf kann nicht ausgeführt werden...

Ein Thema von Mossi · begonnen am 10. Jan 2011 · letzter Beitrag vom 10. Jan 2011
Antwort Antwort
Mossi

Registriert seit: 6. Feb 2004
Ort: Wenzenbach
35 Beiträge
 
Delphi 7 Enterprise
 
#1

Fehler: Ein ausgehender Aufruf kann nicht ausgeführt werden...

  Alt 10. Jan 2011, 09:44
Hallo,

ich hab eine kleines Problem, das vermutlich mit Threads zusammen hängt.
Ich verwende MadExcept um einen Bugreport zu erzeugen. Dieser BugReport soll automatisch an einen WebService geschickt werden, was über eine externe Komponente geschieht, die als Com Object eingebunden ist.

Das Registrieren des Handlers sieht folgendermaßen aus:
Delphi-Quellcode:
begin
  Application.Initialize;

  RegisterExceptionHandler(SendBugReportByService, stTrySyncCallAlways, epCompleteReport);
  RegisterExceptActionHandler(WaitForSendBugReportByService, stDontSync);

  ...
end;
Mit stTrySyncCallAlways sollte sichergestellt sein, dass der Handler immer aufgerufen wird und falls möglich im MainThread.

Hier kurz noch die Optionen, die möglich sind mit einer kurzen Beschreibung
Zitat:
// stDontSync: Don't synchronize the handler, instead call it in the context
// of madExcept's exception handling thread.
// + It doesn't matter what the main thread is doing.
// - You must not use the VCL, cause it's not thread safe.
// stTrySyncCallOnSuccess: Try to call the handler in the context of the main thread.
// If the main thread doesn't react, don't call this handler.
// + You may use the VCL, cause the handler is only ever called
// in the context of the main thread.
// - If synchronzation fails, your handler isn't called.
// stTrySyncCallAlways: Try to call the handler in the context of the main thread.
// If the main thread doesn't react, call the handler nevertheless.
// + The handler is always called - and if possible in the context
// of the main thread. In the latter case you may use the VCL.
// - You may use the VCL only if you're in the main thread context.
// (if GetCurrentThreadID = MainThreadID then)
Wenn jetzt der Handler ausgeführt wird und nicht im MainThread läuft, kommt es zu einem EOleSysError mit der folgenden ErrorMessage:
Zitat:
Ein ausgehender Aufruf kann nicht ausgeführt werden, da die Anwendung einen einen Eingabe-Synchronisierten Aufruf weiterleitet
Ser Fehler tritt auf, wenn versucht wird das ComObject zu erstellen:
Delphi-Quellcode:
class procedure TServiceSupport.SendFile(AFile, ADescription: string);
var
  support: _Support;
  supportResult: string;
begin
  support := CoSupport.Create;
  ...
end;
Delphi-Quellcode:
class function CoSupport.Create: _Support;
begin
  Result := CreateComObject(CLASS_Support) as _Support;
end;
Ich vermute, dass das irgendwie damit zusammenhängt, dass ich mich nicht mehr im MainThread befinde. Kann man da irgendwas machen, dass ich dennoch das ComObject erzeugen und aufrufen kann?
  Mit Zitat antworten Zitat
Mossi

Registriert seit: 6. Feb 2004
Ort: Wenzenbach
35 Beiträge
 
Delphi 7 Enterprise
 
#2

AW: Fehler: Ein ausgehender Aufruf kann nicht ausgeführt werden...

  Alt 10. Jan 2011, 14:05
Scheinbar hab ich das Problem gelöst, wobei es noch nicht vollständig ausgetestet ist. Sieht aber erst einmal gut aus.

Als Sync-Option verwende ich jetzt stDontSync
In der Methode, in der ich die COM-Operationen durchführe hab ich außerdem CoInitialize(nil) eingefügt

Delphi-Quellcode:

class procedure TServiceSupport.SendFile(AFile, ADescription: string);
var
  support: _Support;
  supportResult: string;
begin
  try
    CoInitialize(nil);
    support := CoSupport.Create;

    ...

    support.Dispose;
    support := nil;
    CoUninitialize;
  except
    on E: Exception do
    begin
      OutputDebugString(PChar(E.Message));
    end;
  end;
end;
Damit sollte das Ganze dann also grundsätzlich in einem anderen Thread laufen. Mal sehen, auf welche Probleme ich dann damit stoße.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:08 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz