?
Solved

Packages

Posted on 2002-06-27
8
Medium Priority
?
734 Views
Last Modified: 2012-05-04
Using Delphi 6

I've developed a couple of packages that I want to use in a big system but I've run into the following error - "Cannt load package A. It contains unit xxxx which is also contained in package B"

No I've read the help and found the following under the Contains clause: " A unit cannot be contained(directly or indirectly) in more than one pakage used by the same application"

This doesn't make any sence to me. Isn't the whole idea to be able to reuse your code if possible. I know usually I would just have functions that I'd reuse but isn't that the idea of packages and units to.

Please help me out here
Fick
0
Comment
Question by:jfvd
[X]
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
  • 5
  • 3
8 Comments
 
LVL 8

Accepted Solution

by:
TOndrej earned 800 total points
ID: 7115303
Simply include package B in the 'requires' clause of the package A.
0
 

Author Comment

by:jfvd
ID: 7116330
I don't think that'll really work for my problem ... I've got units that's being used in package A and B and then both packages are used in an App for different functions.

I understand that I've got to make a "common" package that's used by both packages or something like that but I'm not sure.

What I need to do:
 A uses units x1, x2, y1, z1
 B uses units x1, y1, z2

The error I get is that x1, y1 is contained in A or B depending on which I try to execute first. Also some of the common packages has form that I need in both.

Hope this clears it up a bit.
 Fick
0
 

Author Comment

by:jfvd
ID: 7116454
I seem to have managed to get around the first problem but now I get the following error in my main app: "A class named TraTObjectRTTI already exists"

I've also got a little dummy program where I call the same to packages and I don't get the same error in there.

Please advise
 Thanx
  Fick
0
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!

 

Author Comment

by:jfvd
ID: 7116779
The error mentioned in the last post occurs on the following line:
 XferPck := LoadPackage('POSTransfers.bpl');

( XferPck : HModule)

What stumps me is that the same code works in a little dummy app I've put together.
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 7116967
> I don't think that'll really work for my problem

It was the correct answer to the original question. It's all documented in the help.

> "A class named TraTObjectRTTI already exists"

You're attempting to register the class twice.

In the original question you did not mention you're loading runtime packages dynamically.
I have created such a system and it worked without problems.

Sorry, I have no time for twenty questions.
Ask a question if you can. I will answer if I can.
Wish you good luck.
0
 

Author Comment

by:jfvd
ID: 7117164
Thanx

Is there any way to determine which class it is that I'm regestering twise?

0
 
LVL 8

Expert Comment

by:TOndrej
ID: 7117253
> "A class named TraTObjectRTTI already exists"
I guess it's TraTObjectRTTI in this case...
0
 

Author Comment

by:jfvd
ID: 7117264
Thanx

I got the culprit. It would seem that delphi just give the classes generic names if they're being loaded dynamicaly. In my instance it was called objMWXfer but as it was RTTI that was involved ... I don't know.

Thanx for your time though.
 Have good weekend.
  Fick
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

771 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