Solved

loading packages dynamically which have duplicate classnames

Posted on 2007-04-11
3
255 Views
Last Modified: 2012-05-05
How can I load packages dynamically which may have duplicate classnames?

For example

I have two packages

Package 1 contains, say 500 forms

Package 2 contains another 1000 forms

Most of the forms in each package depend or relate to each other in some degree.

Also a number of forms in each package (say 50) refer to a form(s ) in the other package.

For example, we have a contact management package. One of the forms in this allows the user to perform a sales order inquiry - but this is in the Sales Package. The Sales order inquiry pulls in say, Stock Inquiry. This is in the Stock Module.

What we now have in the Contact Manager module, when it is built, the Sales Order inquiry screen is compiled (together with all it's dependencies) and also the Stock Inquiry screen (together with all it's requirements).

Loading the Stock Module is fine.

Loading the Contact Manager results in EFilerError " A Class named xxxx already exists..".

Now, these classes are going to be the same.

Is there anyway of suppressing/ignoring this error and loading the complete Contact Manager module.

If not, can you suggest a way to overcome the above situation.

Thanks

Steve






0
Comment
Question by:steve-west
  • 2
3 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 18918956
I am guessing you are having the same class name used in 2 different units. is that so? (you can check by searching for the class name in all files (using total commander for example or some other file manager). if that is tha case, you need to either merge the 2 units or at least class definition, or rename one of them.
there is no way of having 2 different class definition with the same name loaded at design time. you will have to somehow make it one.
if what I say is not what you have, maybe an exact example will help better understand your situation and fix it.
0
 

Author Comment

by:steve-west
ID: 18990255
Hi Ciuly:

I'd pretty much resigned myself to what you've just explained.

I'm having to ensure that a class reference is held in a only one module (package). The cross-module referencing means that this is a really painful and laborious task (I didn't realise it also extended to units - you can only have a unit referenced in a single package - not multiple!!!).;

Thanks for your help.

Regards

Steve


0
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 18990411
well, the other solution is not to load the packages into the ide, and only add it to each project you will work with (since you will not be using both packages in the same projet... are you? if you do, then you otehr solution is to not even add the packages to teh project, but add the units to the project searchpath. AND keep in mind that in a uses clause if you have:

uses unit1, unit2;
and unit1 has a TMYClass class definition and so does unit2, then  the actual class used will be the one form unit2.

so, if you also need to use the same 2 different classes with the same definition in the same unit, your only solution is to add the unit name in front like:

var c1:unit1.TMYClass; c2:unit2.TMYClass;

in which case c1 will be of a different type then c2. but of course this approach means you will have to pay a very very much attention to uses clauses and var/property declarations otherwise there will be a mess.
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

Suggested Solutions

Title # Comments Views Activity
Send message from delphi to whatsapp, is it possible? 3 1,178
Reconfigure Delphi Install? 2 46
Find and Replace Stream with 0s 8 57
When i run adoquery my application freezes 26 150
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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

11 Experts available now in Live!

Get 1:1 Help Now