1

In my solution I have 4 projects named UI,Business,Data and common.In the Data project I have an app.config file with following values

<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
 <appSettings>
 <add key="LibrarySystemConnection" value="server=(local);Initial Catalog=SanasaLibrarySystem;Integrated Security=True;
     User ID=sa;Password=123"/>
 </appSettings>
 </configuration>

In a class of the Data project I am accessing the above key as follows:

connectionString = ConfigurationSettings.AppSettings["LibrarySystemConnection"];

When I run the code the connectionString retuns null.Anybody have an idea what is the wrong in the code

udaya726
  • 1,010
  • 6
  • 21
  • 41

2 Answers2

1

You should move the app.config file to your primary UI project.

msigman
  • 4,474
  • 2
  • 20
  • 32
1

Either move the app.config file to the project which generates exe or read the config from the assembley using this

Community
  • 1
  • 1
luqi
  • 2,779
  • 2
  • 18
  • 14