TstringList can not assign

Posted on 2001-08-12
Last Modified: 2010-04-06

I create a dll with delphi and try to connect to the Dll by delphi application

One of the function in the Dll has parameter from type TStringList.

When i try to use this function i get an error :
"TstringList can not assign to TstringList"

i use StrList1.assign(StrList2)

and every unit has the ShareMem unit,

why ?

Question by:asi
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3

Expert Comment

ID: 6377357


Try declaring sharemem in the project source of your exe and dll rather than in every unit. You also need to ensure that it is declared first.

Author Comment

ID: 6377366
finally i find out  the Vcl objects cannot pass to Dll ...

10x to me

Expert Comment

ID: 6377597

you should be able to post objects between an exe and a dll without any problem. Problems only occur if you start using strings over 255 characters.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 21

Expert Comment

ID: 6377608
Are the string lists in the dll or in the exe?

Try using Form1.StringLIst.Assign(Form2.StringList);

Replacing Form# with your form names....


Accepted Solution

fva earned 50 total points
ID: 6379186
The Assign method checks for the class of the parameter using probably the "is" operator or "InheritsFrom". Both rely on the virtual tables being the same, which is not the case unless you compiled both your EXE and your DLL with runtime libs.
Resolution: Compile with runtime libraries (packages) both the EXE and the DLL
Don't use Assign, rather make your own copying routine

I would go for the first option if it's affordable, since the different VT issue might get you in other kinds of trouble later.


Author Comment

ID: 6380269
and if i want to get from a Dll Tdataset ? the same ... ?

Expert Comment

ID: 6380332
If the object you are trying to use across the "DLL boundary" does not make any awkward use of internal workings of the compiler (as the case I outlined) or some global vars then you might get away with it. The sad fact is that when you run a method of any object from within the DLL, code inside the DLL gets run and when you call the same method on the same object from within the EXE _other_identical_piece_of_code_ will run. Things can go very well as long as that code does not make use of any globals (and the VT is such a "hidden" global).
When you run into globals you _will_ have to switch to runtime libs. The database subsystem of the VCL is built on global stuff (see the Session or the Sessions variables) so you will have a very hard time to DLL-ize database code without runtime packages.
When using RT packages every module (EXE and all involved DLL's) is expected to use the same vclxxx.dpl, meaning that all the globals I mentioned above are in the same place (a.k.a. in those DPL's)


Expert Comment

ID: 6844660
Question(s) below appears to have been abandoned. ADMINISTRATION HAS BEEN ADVISED AND WILL BE CONTACTING YOU SHORTLY.  There are a total of 57 open questions for you, any not shown here have ZERO comments added, so you can delete them directly.

Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.
Thank you everyone.
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.

Expert Comment

ID: 6887782
Admin notified of User neglect. Force-accepted by
Community Support Moderator
Experts Exchange

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle global variables 4 80
Reconfigure Delphi Install? 2 76
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 100
Firemonkey android show image from resource ? 1 72
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question