Adding code modules programmatically to Ranorex

Class library usage, coding and language questions.
Lex
Posts: 6
Joined: Mon Sep 30, 2019 7:38 pm

Adding code modules programmatically to Ranorex

Post by Lex » Fri Nov 15, 2019 9:09 pm

Hello,

Lately I’ve been working on generating simple code modules which do simple things for our automations. I have no issues adding them to the Visual Studio solution but once I try to run them in ranorex I get the Module Could Not Be Found error. I was wondering if anyone has a potential fix for this.

The only potential fix we have found it adding them through the editor but Ranorex doesn’t have an add folder which adds everything in it or a copy/add all button, it makes it so we have to spam a button which kinda defeats the point of doing this programmatically.

If anyone has any information that could help me out it would be greatly appreciated.

Thank you,
Lex

Edit: I’ve found the answer for anyone else who runs into this problem in the future. Surprisingly the missing module has nothing to do with ranorex. In the .csproj file when you use Microsoft.Build.Evaluation.Project.AddFile it doesn’t automatically tag your objects to be compiled. I’ve written something that simply edits the the .csproj file now.
Last edited by Lex on Mon Nov 18, 2019 5:35 pm, edited 1 time in total.

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

Re: Adding code modules programmatically to Ranorex

Post by odklizec » Mon Nov 18, 2019 9:59 am

Hi,

I'm afraid, there is no (publicly available) way to achieve what you want via code. I would suggest to create a feature request here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex
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

cparsons
Posts: 1
Joined: Tue May 29, 2018 10:39 pm

Re: Adding code modules programmatically to Ranorex

Post by cparsons » Fri Dec 27, 2019 8:07 pm

Lex wrote:
Fri Nov 15, 2019 9:09 pm

Edit: I’ve found the answer for anyone else who runs into this problem in the future. Surprisingly the missing module has nothing to do with ranorex. In the .csproj file when you use Microsoft.Build.Evaluation.Project.AddFile it doesn’t automatically tag your objects to be compiled. I’ve written something that simply edits the the .csproj file now.
Hey, Lex. How exactly did you solve the problem with the .csproj file? We are looking into this as well and have had some issues with this as well. What was the code that you wrote?

Thanks,
Cole

Lex
Posts: 6
Joined: Mon Sep 30, 2019 7:38 pm

Re: Adding code modules programmatically to Ranorex

Post by Lex » Tue Feb 11, 2020 6:24 pm

Hey Cole,

I haven’t been using the forums much in the past month since you replied so I apologize for the delay.

I hope you’ve figured it out, but I’ll still inform you of my solution.

Using the XmlDocument class in the Xml c# library, I simply added new nodes to the ItemGroup node which contained Compile nodes. From there you generate a new node with the name Compile, give it an attribute with the name Include and the path as a value, then give this node a child named ID. The ID child’s inner text is simply a newly generated GUID which you get from the system library.