Board index » delphi » cannot assign a tstringlisto to a tstringlist (in a dll)

cannot assign a tstringlisto to a tstringlist (in a dll)


2005-02-10 10:55:53 PM
delphi121
I've a program that calls a procedure in a dll passing a StringList as
a parameter.
In this dll the procedure attempts to assign this StringList to
another StringList, but this causes an exception.
Is this a Vcl bug ?
Regards
Maurizio
Please note : both the main program than the dll USE ShareMem;
---- In the main program :
procedure process(alist:tStringList); external 'mydll.dll';
procedure TForm1.Button1Click(Sender: TObject);
var l : tstringlist;
begin
l := tstringList.create;
try
l.add ('first');
l.add ('second');
process (l);
showmessage (inttostr(l.count)); // just to test
finally
l.free;
end;
end;
----- in the dll :
procedure process (l:tStringList);
var temp: tStringList;
i : integer;
begin
Temp := tStringList.create;
try
Temp.assign(l); // ------ this gives an exception !!!
l.clear;
for I := 0 to temp.count-1 do begin
l.add(temp[I]); // just to do something
l.add(temp[I]);
end;
finally
temp.free;
end;
end;
 
 

Re:cannot assign a tstringlisto to a tstringlist (in a dll)

Are you using the Assign method of the TStringList, ala:
stringlistA.Assign (stringlistB);
Maurizio Ferreira <XXXX@XXXXX.COM>writes:
Quote
I've a program that calls a procedure in a dll passing a StringList as
a parameter.

In this dll the procedure attempts to assign this StringList to
another StringList, but this causes an exception.

Is this a Vcl bug ?

Regards
Maurizio

Please note : both the main program than the dll USE ShareMem;

---- In the main program :

procedure process(alist:tStringList); external 'mydll.dll';

procedure TForm1.Button1Click(Sender: TObject);
var l : tstringlist;
begin
l := tstringList.create;
try
l.add ('first');
l.add ('second');
process (l);
showmessage (inttostr(l.count)); // just to test
finally
l.free;
end;
end;

----- in the dll :

procedure process (l:tStringList);
var temp: tStringList;
i : integer;
begin
Temp := tStringList.create;
try
Temp.assign(l); // ------ this gives an exception !!!
l.clear;
for I := 0 to temp.count-1 do begin
l.add(temp[I]); // just to do something
l.add(temp[I]);
end;
finally
temp.free;
end;
end;

-----------
Don Payette
Unisys Corporation
I speak only for myself; not my employer
Please reply in the newsgroup. Don't try
sending e-mail.
 

Re:cannot assign a tstringlisto to a tstringlist (in a dll)

On Fri, 11 Feb 2005 22:30:28 -0600, Don Payette <XXXX@XXXXX.COM>
writes:
well, where is the problem ?
if I remove the code from the dll and move it in the main programs, it
works.
Regards
Maurizio
Quote
Are you using the Assign method of the TStringList, ala:

stringlistA.Assign (stringlistB);

Maurizio Ferreira <XXXX@XXXXX.COM>writes:

>I've a program that calls a procedure in a dll passing a StringList as
>a parameter.
>
>In this dll the procedure attempts to assign this StringList to
>another StringList, but this causes an exception.
>
>Is this a Vcl bug ?
>
>Regards
>Maurizio
>
>Please note : both the main program than the dll USE ShareMem;
>
>---- In the main program :
>
>procedure process(alist:tStringList); external 'mydll.dll';
>
>procedure TForm1.Button1Click(Sender: TObject);
>var l : tstringlist;
>begin
>l := tstringList.create;
>try
>l.add ('first');
>l.add ('second');
>process (l);
>showmessage (inttostr(l.count)); // just to test
>finally
>l.free;
>end;
>end;
>
>----- in the dll :
>
>procedure process (l:tStringList);
>var temp: tStringList;
>i : integer;
>begin
>Temp := tStringList.create;
>try
>Temp.assign(l); // ------ this gives an exception !!!
>l.clear;
>for I := 0 to temp.count-1 do begin
>l.add(temp[I]); // just to do something
>l.add(temp[I]);
>end;
>finally
>temp.free;
>end;
>end;
>

-----------
Don Payette
Unisys Corporation
I speak only for myself; not my employer
Please reply in the newsgroup. Don't try
sending e-mail.
 

Re:cannot assign a tstringlisto to a tstringlist (in a dll)

The problem is, you didn't answer my question. Did you
use the Assign method?
Maurizio Ferreira <XXXX@XXXXX.COM>writes:
Quote
On Fri, 11 Feb 2005 22:30:28 -0600, Don Payette <XXXX@XXXXX.COM>
writes:

well, where is the problem ?

if I remove the code from the dll and move it in the main programs, it
works.

Regards
Maurizio


>Are you using the Assign method of the TStringList, ala:
>
>stringlistA.Assign (stringlistB);
>
>Maurizio Ferreira <XXXX@XXXXX.COM>writes:
>
>>I've a program that calls a procedure in a dll passing a StringList as
>>a parameter.
>>
>>In this dll the procedure attempts to assign this StringList to
>>another StringList, but this causes an exception.
>>
>>Is this a Vcl bug ?
>>
>>Regards
>>Maurizio
>>
>>Please note : both the main program than the dll USE ShareMem;
>>
>>---- In the main program :
>>
>>procedure process(alist:tStringList); external 'mydll.dll';
>>
>>procedure TForm1.Button1Click(Sender: TObject);
>>var l : tstringlist;
>>begin
>>l := tstringList.create;
>>try
>>l.add ('first');
>>l.add ('second');
>>process (l);
>>showmessage (inttostr(l.count)); // just to test
>>finally
>>l.free;
>>end;
>>end;
>>
>>----- in the dll :
>>
>>procedure process (l:tStringList);
>>var temp: tStringList;
>>i : integer;
>>begin
>>Temp := tStringList.create;
>>try
>>Temp.assign(l); // ------ this gives an exception !!!
>>l.clear;
>>for I := 0 to temp.count-1 do begin
>>l.add(temp[I]); // just to do something
>>l.add(temp[I]);
>>end;
>>finally
>>temp.free;
>>end;
>>end;
>>
>
>-----------
>Don Payette
>Unisys Corporation
>I speak only for myself; not my employer
>Please reply in the newsgroup. Don't try
>sending e-mail.
-----------
Don Payette
Unisys Corporation
I speak only for myself; not my employer
Please reply in the newsgroup. Don't try
sending e-mail.
 

Re:cannot assign a tstringlisto to a tstringlist (in a dll)

Quote
The problem is, you didn't answer my question. Did you
use the Assign method?
Sure I use it !
Perhaps yout didn't had a chance to read my previous post.
I've a program that calls a procedure in a dll.
Both are compiled with uses sharemem as the first unit.
---- this is the program
procedure process(alist:tStringList); external 'mydll.dll';
procedure TForm1.Button1Click(Sender: TObject);
var l : tstringlist;
begin
l := tstringList.create;
try
l.add ('first');
l.add ('second');
process (l);
showmessage (inttostr(l.count)); // just to test
finally
l.free;
end;
end;
---- and this the dll
procedure process (l:tStringList);
var temp: tStringList;
i : integer;
begin
Temp := tStringList.create;
try
Temp.assign(l); // This is the assign that gives an exception
l.clear;
for I := 0 to temp.count-1 do begin
l.add(temp[I]); // just to do something
l.add(temp[I]);
end;
finally
temp.free;
end;
As you can see, the temp.assign is called, and this gives the
exception.
if I move the procedure inside the program, it works !
(btw, I am using Delphi 7)
Regards
Maurizio