Einzelnen Beitrag anzeigen

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