Ranorex Studio adds Ranorex libs to every project

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

Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Fri Sep 29, 2017 3:29 pm

Ranorex 7.1.2
Windows 10 Pro

Ranorex Studio attempts to add the Ranorex libraries to projects, even if the libraries are already referenced through NuGet packages.

I have created a local NuGet package for the Ranorex 7.1.2 libraries since our shop uses those for all library references in our .NET projects. This works perfectly when using Visual Studio or compiling in an environment where Ranorex is not installed locally.

However, when I attempt to open the same project in Ranorex Studio, Studio pops up an error dialog saying "Can't load file XXX.rxsln under C:\GitRepo\XXX. Check the file permission and the existence of that file." This points to an exception and stack trace saying that it can't install a Ranorex plugin because the key already exists:

Code: Select all

2017-09-29 08:35:09.201| INFO|Ranorex.Studio|Ranorex.Core.RanorexCoreException: Failed to load plugins from assembly 'Ranorex.Plugin.Mobile, Version=7.1.2.0, Culture=neutral, PublicKeyToken=b798506b574ebc9a'. ---> Ranorex.Core.RanorexCoreException: Failed to construct plugin 'Ranorex.Plugin.Mobile.RxIntegration.MobileAndroidRemotePlugin' from assembly 'Ranorex.Plugin.Mobile, Version=7.1.2.0, Culture=neutral, PublicKeyToken=b798506b574ebc9a'. ---> System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Ranorex.Core.Remote.Service.RemotePluginService.Register(RemotePlugin plugin)
   at Ranorex.Core.PluginManager.ScanPlugin(Assembly assembly)
   --- End of inner exception stack trace ---
   at Ranorex.Core.PluginManager.ScanPlugin(Assembly assembly)
   at Ranorex.Core.PluginManager.LoadPluginsFromAssembly(Assembly assembly, IEnumerable`1& loadedPlugins)
   --- End of inner exception stack trace ---
   at Ranorex.Core.PluginManager.LoadPluginsFromAssembly(Assembly assembly, IEnumerable`1& loadedPlugins)
   at Ranorex.Core.PluginManager.RescanExtensionPlugins()
   at Ranorex.Addins.PluginChangeDetectionCommand.OnSolutionLoaded()
   at ICSharpCode.SharpDevelop.Gui.AutostartCommandBase.HandleProjectServiceSolutionLoaded(Object sender, SolutionEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at ICSharpCode.SharpDevelop.Project.ProjectService.OnSolutionLoaded(SolutionEventArgs e)
   at ICSharpCode.SharpDevelop.Project.ProjectService.LoadSolutionInternal(String fileName)
   at ICSharpCode.Core.FileUtility.<>c__DisplayClass73_0.<ObservedLoad>b__0()
   at ICSharpCode.Core.FileUtility.ObservedLoad(FileOperationDelegate loadFile, String fileName, String message, FileErrorPolicy policy)
Shortcuts usually aren't...

User avatar
RobinHood42
Posts: 240
Joined: Fri Jan 09, 2015 3:24 pm

Re: Ranorex Studio adds Ranorex libs to every project

Post by RobinHood42 » Mon Oct 02, 2017 10:02 am

Hi krstcs,

I also had several minor issues with DLL's when using Ranorex 7.1.2. Those issues where addressed and fixed with Ranorex 7.2.0. Maybe you could also try updating Ranorex?

If the issue still occurs, I would suggest sending the NuGet package to Ranorex staff to replicate the issue.

Cheers,
Robin

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Tue Oct 03, 2017 2:00 pm

While this issue might be fixed in 7.2.0, I do not update to a new minor version (X.X.0) of Ranorex until the first bug patch is released (X.X.1) due to issues with bugs in new versions, so this is not an option.

However, I doubt this issue is resolved because it appears to be a fundamental problem with how Ranorex Studio tries to inject references into Ranorex projects and doesn't look at any other reference source like NuGet packages.
Shortcuts usually aren't...

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by ahoisl » Tue Oct 03, 2017 10:19 pm

From the stacktrace I suspect that the case of this exception is not necessarily the additional references, but the Nuget package. Some while ago we added the possibility to load plugin extensions inside Studio using Nuget packages. Ranorex scans the "packages" directory for DLLs that may be Ranorex plugins and if it finds any, tries to load those plugins.
As you have a Nuget package with Ranorex Plugin DLLs, Studio tries to load the plugins in those DLLs again - although they are already loaded since they are default plugins.

I think I found a workaround for your use case though: Studio really just searches the "packages" folder for plugins. If you configure Nuget to store your packages in a differently named directory, you could at least get a step further, i.e. open the solution without getting an exception.

Just add a "nuget.config" file next to the solution (*.rxsln) file with the following content:

Code: Select all

<configuration>
  <config>
    <add key="repositoryPath" value="MyPackagesLocation" />
  </config>
</configuration>
Then delete the "packages" folder, open the solution again, and restore the packages.
Hope you can give it a try!

Regards,
Alex
Ranorex Team

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Thu Oct 05, 2017 1:29 pm

Thanks Alex, I'll try it and let you know how it works.
Shortcuts usually aren't...

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Thu Oct 05, 2017 2:27 pm

OK, I've got it working this way now.

Alex, is this something that is going to be "fixed" or reworked on the Ranorex side? I would love to see Ranorex Studio move completely to using NuGet packages instead of direct library injection because it would make it much easier to manage everything. I've already got a feature request for an official Ranorex NuGet package on UserVoice, but it would be nice to see RXStudio start using that package as well so everything would work the same way, especially since most .NET libraries are moving to NuGet packaging.
Shortcuts usually aren't...

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Thu Oct 05, 2017 2:40 pm

Just an FYI, there is one other thing to be aware of for anyone else that is messing with this.

This now conflicts with .gitignore and requires some rework of the .gitignore file by adding the new package location so git doesn't add the packages to the code repo.

This will probably also be an issue for other version control systems.
Shortcuts usually aren't...

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by ahoisl » Tue Oct 10, 2017 4:02 pm

krstcs wrote:Alex, is this something that is going to be "fixed" or reworked on the Ranorex side?
At least one Ranorex integration is relying on the mechanism to load nuget DLLs as Ranorex plugins right now, so changing that mechanism to support both the integration and a Ranorex nuget package may take some time. I can't even assure you that we can fix it, so I hope you can live with the workaround for now.
krstcs wrote: I would love to see Ranorex Studio move completely to using NuGet packages instead of direct library injection because it would make it much easier to manage everything.
There's a subtle difference here when compared to normal NuGet packages. Ranorex Studio is currently bound to a specific version of the Ranorex DLLs and all the tools inside it (Spy, Recorder, ...) work with that version and expect the runtime also to comply with that version. So you would not be able to just use any "Ranorex NuGet runtime" package with every Ranorex Studio version.

However, in the long run, using a runtime Ranorex NuGet package is definitely an interesting idea, as it would decouple the Ranorex tools from the runtime. The functionality that loads Ranorex plugins from NuGet packages (that caused problems for you) would actually help with that. And we are currently working on removing the GAC requirement for Ranorex, which is also a step towards such a functionality.

Let's see if your feature idea gets a few more upvotes in the future when everyone is moving to using packages :-)

Regards,
Alex
Ranorex Team

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Tue Oct 10, 2017 4:25 pm

Awesome! Thanks Alex, that explanation helps a lot!

Edit to add:
Oh, and your work-around does help, except that I found an issue with stdole.dll. It appears to be required for (most likely) the Ranorex Office Interop support, but there are conflicts in certain situations due to the newer version of Office on my local system. It shouldn't matter on test systems as they won't have Office installed, but I'm still trying to figure out if it's worth doing all of this right now anyway.

There is also the matter of Ranorex using Newtonsoft.Json 6, where I was trying to use 10. I don't like warnings in my code, so that bugs me (no pun intended!). But, I may just go with 6 anyway since it may not matter for what I'm doing with it.

Anyway, thanks again for the help on this!
Shortcuts usually aren't...

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Ranorex Studio adds Ranorex libs to every project

Post by Vaughan.Douglas » Tue Oct 10, 2017 5:23 pm

krstcs wrote:OK, I've got it working this way now.

Alex, is this something that is going to be "fixed" or reworked on the Ranorex side? I would love to see Ranorex Studio move completely to using NuGet packages instead of direct library injection because it would make it much easier to manage everything. I've already got a feature request for an official Ranorex NuGet package on UserVoice, but it would be nice to see RXStudio start using that package as well so everything would work the same way, especially since most .NET libraries are moving to NuGet packaging.
ahoisl wrote:Let's see if your feature idea gets a few more upvotes in the future when everyone is moving to using packages
Thought a link to the suggestion would be helpful. Please correct me if this is the wrong one.
Doug Vaughan

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

Re: Ranorex Studio adds Ranorex libs to every project

Post by krstcs » Tue Oct 10, 2017 5:53 pm

That's it.

By the way, and off topic: I just posted something I think you might find interesting Douglas.

https://www.ranorex.com/forum/hidden-fe ... 11434.html
Shortcuts usually aren't...