Problem in reading App.Config file

mohantyd used Ask the Experts™
I have a config file in my classLibrary from where i am reading connection string.
<?xml version="1.0" encoding="utf-8" ?>
    <add key="OracleConnectionString" value="Data Source=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx="System.Data.OracleClient"/>

string connectionString = ConfigurationSettings.AppSettings["OracleConnectionString"];

I am reading above line from my C# project .. but not able to get any value . This is a class library project
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
 ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();

   Configuration config;
            fileMap.ExeConfigFilename = fileMap.ExeConfigFilename  = @"C:\YourPath\yourApp.exe.config";
            config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None) as Configuration;

            string connectionString = = config.AppSettings.Settings["OracleConnectionString"].Value.ToString();
sorry the InitializeComponent, of course, shouldn't be in there.
Hello ,

As per my thinking you are creating Class Library project. Am i right ?

If yes then library can not run independently .. it is included in some another application . For example i have one window form application in which i am using this library. so at that time library point to configuration file of Window Form Application.

So what ever setting for library put it into Window Form Application conifig file . It is solve your problem.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial