Configuration file

A

Alan T

I have created a class library called Employee.dll and created a
configuration file called Convert.config in this project.
What should I use to open this config file:
<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="employee" value="run batch file"/>

</appSettings>

</configuration>



This is my source code:

Configuration config =
ConfigurationManager.OpenExeConfiguration(Utils.GetCurrentAssemblyPath() +
@"\Convert.config");

AppSettingsSection appSettings = config.AppSettings as AppSettingsSection;



But I got exception:

An error occurred loading a configuration file: The parameter 'exePath' is
invalid.

Parameter name: exePath.
 
G

Glenn

Alan

You can get the configuration value from the appSettings node using

string value = ConfigurationManager.AppSettings["employee"]

There's no need to instantiate ConfigurationManager.

HTH

Glenn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top