How to access Project B re usable functions from Project A

Ask general questions here.
theraviz
Posts: 9
Joined: Sun Apr 14, 2019 9:46 am

How to access Project B re usable functions from Project A

Post by theraviz » Mon Apr 15, 2019 9:31 am

Hello,

I have 2 projects in my Ranorex solution- Project A and Project B. I want to access a User code Method (reusable function) which is defined in Project B from Project A.

Added the Project B reference in Project A and I am able to see the User Code in the “Local and Derived Method” listing in Project A.

But after I add the function and when I execute the user code I am getting the below compiler error .

The name 'xxx' does not exist in the current context (CS0103) - C:\Users\xxx\Documents\Ranorex\RanorexStudio Projects\Delete\Delete\ARecording1.cs:82,13”

How to solve this issue so as to create and access reusable functions across multiple projects?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4924
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to access Project B re usable functions from Project A

Post by odklizec » Mon Apr 15, 2019 12:07 pm

Hi,

Aside referencing one project in another, I think you must also add the class with reusable function from ProjectB in code module of project A, in which you want to use the function from ProjectB, e.g. something like this...
using ProjectB.UserCodeCollection;
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theraviz
Posts: 9
Joined: Sun Apr 14, 2019 9:46 am

Re: How to access Project B re usable functions from Project A

Post by theraviz » Mon Apr 15, 2019 12:12 pm

Hello,

Namespace was already added. But no luck.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4924
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to access Project B re usable functions from Project A

Post by odklizec » Mon Apr 15, 2019 12:36 pm

Hi,

Could you please share your solution? Eventually, if you can't publish your production solution, try to recreate the issue with new solution and two empty projects. Thanks.

BTW, what Ranorex version do you use? Please make sure you are using the most recent one (9.0.1).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theraviz
Posts: 9
Joined: Sun Apr 14, 2019 9:46 am

Re: How to access Project B re usable functions from Project A

Post by theraviz » Mon Apr 15, 2019 12:51 pm

Hello,

I just changed the function signature to public static for all the calling functions including the objects.. Now it is working.

Dont know whether this is the right approach but working now. Thanks