Referencing Ranorex DLL files in VS for Ranorex 8.1

Ask general questions here.
User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Referencing Ranorex DLL files in VS for Ranorex 8.1

Post by Aracknid » Fri Apr 06, 2018 8:17 pm

HI,

Sorry if this will sound confusing. I'm not very strong in this area....

I've been using Ranorex for years, since version 3. I also use VS to create my framework DLL(s) and all my scripts are 1 console project each (compiled to an EXE). Usually when I update Ranorex on my system, it still works and automatically finds the newer Ranorex DLL files referenced in my projects. If you were to look in one of my framework DLL project files, you would see that it is looking for a 3.0.xxx version of the Ranorex.Core.Dll. Of course I've not been using version 3 for a long time, and it always just magically finds the latest version's Dll and compiles.

When I installed Ranorex 8.1 (upgrading from 7.2) and I loaded my main framework DLL, it complained about being unable to find the Ranorex references and also something complaining about .NET. My Project was set to .NET 4.0, so I changed it to .NET 4.5.2. This fixed some issue but still couldn't find the Ranorex files.

To resolve this, I went into references section of project properties and added a path to the Ranorex 8.1 bin folder, which then solved the problem. But actually what it does is create a project USER file with a reference path in this file to Ranorex bin folder. It means I need to add this new file to TFS and luckily when I build using msbuild it uses this file to find the DLL's.

OK, so this ended up solving my problem for my framework dll. I checked out all the files in my whole suite and manually did a find/replace in all to console app (scripts) project files to upgrade them all to .NET 4.5.2 and I also needed to add a reference to an app.config file (which was new as well, telling it to use .net 4.5.2). Long story short, everything builds and I can run my scrips....

Except there is a problem... some scripts crash because they cannot find a specific Ranorex.Plugin.*.DLL files. The folder that contains all my built EXE files and DLL files also contains the required referenced Ranorex DLL's (because copy was set to true in the reference properties settings). But it's complaining about some DLL files I don't even need (or think I don't need). The first time it complained about needing Ranorex.Plugin.Winforms.DLL, so I copied it over manually and then it complained about ChromeWeb (I'm not even running in Chrome for this test), then FireFoxWeb (which I was running in) and then Flex which I don't even use... SO I gave up. I should point out that this is spread across 14 machines, and happened on some of them but not all of them. Many test ran and passed.

I thought maybe if I added the path to the Ranorex bin files to the system path environment variable, it would help, but it does not.

Any thoughts on this?

Thanks,

Aracknid

User avatar
Vega
Posts: 109
Joined: Mon Jul 11, 2016 2:15 pm

Re: Referencing Ranorex DLL files in VS for Ranorex 8.1

Post by Vega » Wed Apr 11, 2018 8:29 am

Hi,

I had something somewhat similar (but on just one machine) happen to me after an upgrade but I did a clean solution and then a fresh build afterward and it worked.

"The first time it complained about needing Ranorex.Plugin.Winforms.DLL, so I copied it over manually"

Where did you copy it to? It should be in the bin\debug folder since you are using copy runtime to output right? In any of the errors did you notice it complaining about a specific version of the DLL? Maybe an older version?

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Referencing Ranorex DLL files in VS for Ranorex 8.1

Post by Aracknid » Wed Apr 11, 2018 2:23 pm

I also did a clean build and that didn't help (but I know that this is what I've done in the past with previous upgrades and it did work for those older upgrades).

I've temporarily fixed my problem by copying ALL the Ranorex DLL files from the Ranorex Bin folder into my folder that holds all my compiled EXE's. This did resolve the problem, but I know this was not really the right thing to do.

Clearly something is wrong in my environment, I'm just wondering what it is... Is there a way to make sure the Ranorex DLL files are properly registered? Not sure if that is the issue.

Thanks,

Matt.

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: Referencing Ranorex DLL files in VS for Ranorex 8.1

Post by ahoisl » Wed Apr 11, 2018 4:15 pm

Aracknid wrote:If you were to look in one of my framework DLL project files, you would see that it is looking for a 3.0.xxx version of the Ranorex.Core.Dll. Of course I've not been using version 3 for a long time, and it always just magically finds the latest version's Dll and compiles.
This will probably have to do with the fact that we do not install DLLs into the .NET GAC any more since Ranorex 8.0. The GAC is kind of a local registry for DLLs and MSBuild by default searches that registry first - and usually takes a DLL from there if it can find a match.

Do you have some "hintpath" values in the references? If so, you can set that to the correct path in the Ranorex installation "bin" directory.

However, a probably better alternative is to remove the "hintpath" altogether and import the "Ranorex.MSBuild.Targets" into your project which will then care about resolving the DLLs. If you open the project with Ranorex Studio, it will try to set the references right. This is sadly not fail-proof due to the complexity of MSBuild projects, so if it fails, you can also compare your project file with a new one generated by Ranorex Studio.

Regards,
Alex
Ranorex Team

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Referencing Ranorex DLL files in VS for Ranorex 8.1

Post by Aracknid » Thu Apr 12, 2018 3:22 pm

Thanks for the info.

I checked and I don't have any hintpath tags for the Ranorex dll's in the proj files.

I did a test and opened 1 vbproj file in Ranorex Studio and compared the newly converted result to the original. Looks like the main difference is that it adds this to the top PropertyGroup section:

Code: Select all

<RanorexVersion>8.1</RanorexVersion>
<RanorexTargetsPath>$(MSBuildProgramFiles32)\MSBuild\Ranorex$(RanorexVersion)\Ranorex.MSBuild.Targets</RanorexTargetsPath>
And it adds this to the very bottom of the vbproj file:

Code: Select all

<Import Project="$(RanorexTargetsPath)" Condition="Exists('$(RanorexTargetsPath)')" />
SO I guess if I add these lines to all my vbproj files it will magically work? (I've got to do this to over 1500 files....)

It also adds ALL the Ranorex DLL files as references, but I'm guessing this is a Ranorex Studio thing and I don't actually need this in my VisualStudio proj files.

Thanks,

Aracknid