• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Using a class from a different project

Hey,

I have a solution with three projects, let's call them projectA, projectB and projectC.

ProjectC contains objects of projectA and has a reference to projectB.
ProjectB has a reference to projectA.
However, I want an object in projectA (that is used in projectC) to use a certain class with functions in projectB. The problem is that I cannot add projectB as a reference because this would cause circular dependency (due to the reference projectB has to projectA).

Can anyboy offer me a solution so I can use the functions in the class in projectB? Copying the functions to projectA or removing the reference to projectA in projectB is not an option...

Thanks!
0
tsay
Asked:
tsay
  • 5
  • 4
1 Solution
 
Bob LearnedCommented:
You can link files from one project to another without having to add them physically through the 'Add Item' dialog.  The <Open> button has a drop-down button, which has a 'Link File' option.

Bob
0
 
tsayAuthor Commented:
I have no idea what button you mean? This <open> button?
I want all the logic to stay in projectB...
0
 
Bob LearnedCommented:
1) Add Existing Item
2) Look down at the lower-right hand corner of the dialog box
3) Click on the down-arrow
4) The logic will "stay" in project B, but you will be able to use it in the other project.
5) Usually this situation can be solved by a better class design.


Bob
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
Bob LearnedCommented:
3) Click on the down arrow, and select 'Link File'.

Bob
0
 
tsayAuthor Commented:
I see where you're going at but it won't work. First of all I get some build errors telling me things like ClassIwantToUse is ambiguous?

I know about the class design, wish I could change it but sh*t falls down so I have to deal with it like it is...

Any other solution?
0
 
Bob LearnedCommented:
You are going to have to give me a better description of what you are doing.  Do you already have a class in the project that has the same name as a class from the other project?

Bob
0
 
tsayAuthor Commented:
No there's no class in projectA that is named like the one I want to use from projectB.
0
 
Bob LearnedCommented:
Ok, project B has a reference to project A, so in different way you have created a circular reference.

Bob
0
 
tsayAuthor Commented:
I found the problem, in projectC there is a class that imports from both projectA and projectB, that's why it's ambigious...
0
 
PockyMasterCommented:
Yeah, in that case you need to specify the full namespace in your class name
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now