Page 1 of 1

How do I use classes within another project?

Posted: Fri Aug 19, 2016 10:18 am
by Andymann
Hi Everybody,

The structure of our solution is as follows:

SolutionXY
+----ToolsProject
+----Programmer1_Project
+----Programmer2_Project
+---...

The Projects were added to the Solution via "add | existing Project|...".
Our long-time goal is to fill the "ToolsProject" with completely stable modules etc while in the meantime every programmer has his own project to work in.
We already have a "SuperTools.cs" fie within the TooslProject where we keep our ...super tools :wink:

How would I access this class from usercode modules within, let's say, the "Programmer2_Project" (namespaces, etc.. )?

Re: How do I use classes within another project?

Posted: Mon Aug 22, 2016 11:42 am
by Support Team
Hello Andymann,

You just need to add a reference to your solution:
AddReference.png
Once you have added the reference from one to the other project, you can access the files within the user code:
ReferencedSolution.png
Hope this information helps.

Sincerely,
Robert

Re: How do I use classes within another project?

Posted: Tue Aug 23, 2016 2:18 pm
by Andymann
yepp, that was it


Thx a lot!

Re: How do I use classes within another project?

Posted: Tue Aug 23, 2016 2:27 pm
by krstcs
Note that once you make a reference in one direction, you can't then also make a reference in the opposite direction. This creates a cyclic redundancy (circular reference) that the compiler cannot handle. In your case, that means that your tools library cannot also contain a reference to your personal project.

This is not likely to happen in your case because of how you have the solution set up (I do the same, although I'm the only developer on our Ranorex automation), but I wanted to make this clear so you don't run into it in the future.