How do I use classes within another project?

Ask general questions here.
User avatar
Andymann
Posts: 41
Joined: Wed Jul 27, 2016 12:22 pm
Location: Hamburg
Contact:

How do I use classes within another project?

Post by Andymann » Fri Aug 19, 2016 10:18 am

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.. )?
Vorsprung durch Wahnsinn
www.Doktor-Andy.de

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How do I use classes within another project?

Post by Support Team » Mon Aug 22, 2016 11:42 am

Hello Andymann,

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

Sincerely,
Robert
.
Image

User avatar
Andymann
Posts: 41
Joined: Wed Jul 27, 2016 12:22 pm
Location: Hamburg
Contact:

Re: How do I use classes within another project?

Post by Andymann » Tue Aug 23, 2016 2:18 pm

yepp, that was it


Thx a lot!
Vorsprung durch Wahnsinn
www.Doktor-Andy.de

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How do I use classes within another project?

Post by krstcs » Tue Aug 23, 2016 2:27 pm

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.
Shortcuts usually aren't...