Solved

Packages

Posted on 2002-06-27
8
720 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
  • 5
  • 3
8 Comments
 
LVL 8

Accepted Solution

by:
TOndrej earned 200 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now