In Custom activity Execute method, how to use values from app.config


#1

When builidng a Custom activity in Visual studio, in the Execute method, how to use values from app.config file, app settings section? I have added reference to the System.Configuration namespace, added ‘using System.Configuration’, added the .config.dll file when building the nuget package. But still when i run the custom activity in UiPath studio, it does not read the values from the app.config file


#2

Hi,

This topic may prove useful - http://stackoverflow.com/questions/5674971/app-config-for-a-class-library

In short - app.config is generally on application (robot level in this case), not library level. You culd use a trick (http://stackoverflow.com/a/7262937) to load it, though.

Baring that in mind, since app.config is just an xml file with convenience access through System.Configuration, you could just use a normal xml and read it with XDocument/XPath/your solution of choice, or any other text based format (since it’s plain text anyway, it’s just a matter of convenience, although XML files are the general choice for configs).
Depending on complexity level of the configuration, you could also add them as arguments (or a single argument with path to config file) and store wherever (Orchestrator with a PerRobot asset?).

What kind of values do you need?


#3

Thanks Andrzej!
The values were some configuration information like connection strings, filepaths etc. I used the XML activities instead to make it work.