AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

COM Zeigtoperation problem

Ein Thema von davidm · begonnen am 11. Okt 2006
Antwort Antwort
davidm

Registriert seit: 11. Okt 2006
1 Beiträge
 
Delphi 7 Enterprise
 
#1

COM Zeigtoperation problem

  Alt 11. Okt 2006, 10:50
Ich schereibe es auf Englisch weil cih es auf Englisch besser erklären kann.
Danke für ihre verstandniss.

Ich benutze Delphi 7 enterprise.

I have a COM Exe server and a COM client.

On the client i have diferent threads which create an multiapartment object
on the server. So i got on the main thread a conection with the server:


FMPMCOMServer0001:=CoMPMCOMServer0001.Create;

// Aufruf
mVarLoginErgebniss:=InfoCOM.FMPMCOMServer0001.WMTA Connect(mWMTAConnectInfo.asVariant,mVariantSession Info);
mLoginErgebniss:=TWMTAErrRetType.create(mVarLoginE rgebniss);
//mLoginErgebniss.main_code:=0;
//**********************
If mLoginErgebniss.main_code <> cWM_SUCCESS then
begin
//Fehlerfall
Application.MessageBox('Login: Es konnte keine Verbindung zum Server aufgebaut werden', 'Fehler', MB_OK);
end;


I create another thread in order to launch an dll on the COM server.So is that:

constructor TExeAppThread.CreateExeAppThread(CreateSuspended: boolean;
_Action: TThreadMethod;_Data: TObject{pointer});
var
mTestWorkItemId : string;
begin
ThreadMethod := _Action; // Set these BEFORE calling

Data := _Data; // inherited Create()!

(Data as TInvokeApplication).TaskMPMCOMServer0001 := CoMPMCOMServer0001.Create;

CoMarshalInterThreadInterfaceInStream(IMPMCOMServe r0001,
(Data as TInvokeApplication).TaskMPMCOMServer0001,
IStream(FStream));

FreeOnTerminate := True;
inherited Create(CreateSuspended);
end;

TInvokeApplication is an object where i create a new object with CoMPMCOMServer0001.Create;
I marshall the interface.

And in the Execute that thread I got:


procedure TExeAppThread.Execute;
var
mTaskMPMCOMServer0001 : IMPMCOMServer0001;
hr : integer;
begin
inherited;

hr := CoInitializeEx(nil,COINIT_MULTITHREADED);

if(hr = S_OK) or (hr = S_FALSE) then
try
CoGetInterfaceAndReleaseStream(IStream(FStream),IM PMCOMServer0001,
mTaskMPMCOMServer0001);

(Data as TInvokeApplication).TaskMPMCOMServer0001 := mTaskMPMCOMServer0001;

Assert(Assigned(ThreadMethod));
Data := ThreadMethod(Data);

finally
CoUninitialize;
end;
end;


Hier create the COM object in the COM server like COINIT_MULTITHREADED.
ThreadMethod(Data) call a method who was given as parameter to the thread and that method do:


function InvokeApplicationCOM(const aData : TObject) : TObject;
...
begin

mInvokeApplication:=(aData as TInvokeApplication);

mVarMode_app:=VarArrayCreate([0, 1], varVariant);
mVarMode_app[0]:=mInvokeApplication.Mode_app;


// Aufruf
mVarLoginErgebniss:=mInvokeApplication.TaskMPMCOMS erver0001.WMTAInvokeApplication(...);

...


if mInvokeApplication.Condition=c1 then
...
else if mInvokeApplication.Condition=c2 then
ReqStatusThread(...);
end;
end;

When the c2 is true i call the method ReqStatusThread(...) who create another thread.That thread is like the above one
but it test on the server a value with a timeinterval.So:

procedure TReqStatusThread.Execute;
var
hr : integer;
begin
inherited;

hr := CoInitializeEx(nil,COINIT_MULTITHREADED);

if(hr = S_OK) or (hr = S_FALSE) then
try

CoGetInterfaceAndReleaseStream(IStream(FStream),IM PMCOMServer0001,
FMPMCOMServer0001InThread);

while not Terminated do
begin
Assert(Assigned(ThreadMethod));
ThreadMethod(self);
sleep(FInterval);
end;

finally
CoUninitialize;
end;
end;

It calls one method too.This is:

procedure CheckingStatusIA(aData: TObject);
...
begin
try
mReqStatusThread := (aData as TReqStatusThread);

try

mVarLoginErgebniss:=(mReqStatusThread.GetInterface as IMPMCOMServer0001).WMTARequestAppStatus(...);

if (condition1) or
(condition2) then
begin

...

//HIER EVENT ODER TERMINATE
mReqStatusThread.Terminate;

...

end;

except
...

end;
...

end;

Server side.

The server is configured like mtfree.

The problem.
I can execute from the server once the method who call the dll. All the threads are perfect destroid and I receive all the information from the server
but when i tried to execute a second time that method who call that dll, i rebuild of course all that threads cos
is the same process, it fails. The dll is executed with the rights values but when the method in the server is finish
(the dll call to a dialog form who waits but not block the complete system), i become an error produced by invalid pinter access.
I thouth is was becouse two threads had the same resource, but that method who call the dll is under criticalsections.

I have no idea what exactly is the problem.

More information about the system.
The client is a SOAP client.I dont know if that is relevant or not.

Thanks in advange.
  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 07:41 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