Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
While I'm trying to read connection string which is in App.Config file I'm getting error like "Object reference not set to an instance of an object."
string strconn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString();

For the windows service where I need to keep app.config file and how.

Thanks in advance.
Posted
Updated 31-Aug-10 21:41pm
v2

1 solution

Hi,

Right click on App.Config then
Properties > Copy to Output Directory > Copy always

Then Rebuild the project and run the project

I think it will work
 
Share this answer
 
v2
Comments
Member 12714911 9-Jan-18 5:08am    
I used your solution but my problem still exist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900