Page 1 of 1

passing data from config file

Posted: Wed Sep 14, 2011 10:01 am
by bheemuabhigna
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

Re: passing data from config file

Posted: Wed Sep 14, 2011 3:26 pm
by Support Team
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

Re: passing data from config file

Posted: Thu Sep 15, 2011 7:35 am
by bheemuabhigna
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

Re: passing data from config file

Posted: Thu Sep 15, 2011 11:42 am
by Support Team
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