I have a project of type class library. It has a app.config file which has connection strings. This class library is referenced in an ASP.NET web application. After publishing, the dlls is there in the bin folder but the app.config file is not there. What is the location of the app.config file ?
Asked
Active
Viewed 1,044 times
0
-
What ASP.NET version are you using? – Tom Droste Apr 28 '16 at 17:20
-
I am using .NET Framework 4.5 – Karthik Apr 28 '16 at 17:22
-
1Karthik, if you haven't already have a look at this http://stackoverflow.com/questions/1189364/reading-settings-from-app-config-or-web-config-in-net , it looks similar. I think that with some small code changes in your class lib, you can access the same setting in web.config appSettings section that you have in your app.config. In other words, I don't think your app.config will be available but web.config appSettings will be available. – Jeff Mergler Apr 28 '16 at 17:27
1 Answers
0
If your goal develop Web Application, your main config file is Web.Config. if you add connectionstring to Class Library project App.Config file, the same connectionstring definition set web.config file, so you do not need to app.config file but your develop Console Application App.Config file required.
How to Read Web.Config for Class Library project.
Add System.Configuration.dll references your Class Library project and your define below sample .
System.WebConfigurationManager.AppSettings["value1"];
I hope its help.

rootturk
- 316
- 4
- 20