passing data from config file

Ranorex Spy, Recorder, and Studio.
bheemuabhigna
Posts: 49
Joined: Thu Feb 03, 2011 3:15 pm

passing data from config file

Post by bheemuabhigna » Wed Sep 14, 2011 10:01 am

Hi,

We want to pass some value from config file
I added below code to "C:\Documents and Settings\<User>\Application Data\RanorexConfig3.xml"

<appSettings>
<add key="DBConnectionString" value="Password=xxxx;Persist Security Info=True;User
ID=xxx;Initial Catalog=testing;Data Source=1.1.1.1">
</appSettings>

I am trying to retrive using below code

ConfigurationSettings.AppSettings["DBConnectionString"].ToString();

But I am getting object null reference
Let me know where I have gone wrong

Thanks,
Abhigna

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: passing data from config file

Post by Support Team » Wed Sep 14, 2011 3:26 pm

Hi,
The Ranorex intern parser will ignore your custom tags, therefore you cannot access it through UserCode.
As workaround you can create another XML file which you can read at runtime.
You can use the normal .Net functionality to read such XML files.

Regards,
Markus
Ranorex Support Team
.
Image

bheemuabhigna
Posts: 49
Joined: Thu Feb 03, 2011 3:15 pm

Re: passing data from config file

Post by bheemuabhigna » Thu Sep 15, 2011 7:35 am

Hi Support team,

Thanks for update. I will try this.

What about environment variables.
Can we create environment variable in system and use that in my script?

Thanks,
Abhigna

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: passing data from config file

Post by Support Team » Thu Sep 15, 2011 11:42 am

Hi,

If you mean global variables then this is possible, there is a section in our User Guide which describes this topic very well.
There are also some forum posts: http://www.ranorex.com/forum/post10434.html#p10434 about this topic.

Regards,
Markus
Ranorex Support Team
.
Image