Page 1 of 1

How to access Project B re usable functions from Project A

Posted: Mon Apr 15, 2019 9:31 am
by theraviz
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?

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

Posted: Mon Apr 15, 2019 12:07 pm
by odklizec
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;

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

Posted: Mon Apr 15, 2019 12:12 pm
by theraviz
Hello,

Namespace was already added. But no luck.

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

Posted: Mon Apr 15, 2019 12:36 pm
by odklizec
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).

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

Posted: Mon Apr 15, 2019 12:51 pm
by theraviz
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