I have an solution in VS 2008 which contains two class library projects and an ASP.NET web site. The ASP.NET site references the class libraries and one of the libraries contains a LINQ To SQL item.
My question is with regards to the app.config in the class library which contains the connection string for the database. When I build the project, this app.config isn’t within the build directory and this means I can’t dynamically change the connection string for the deployed project.
What am I doing wrong here, how can I have these settings deployed too so I can make changes to the connection string?
Thanks in advance,
Martin.
This caused me a bit of confusion at first as well.
You might think that the class library uses the app.config file that’s contained in it’s own project but it doesn’t. It uses the config file of the project that is referencing it.
So what you need to do is look for the
<appSettings/>tag inside the web.config file of your ASP.Net project and change it to<appSettings></appSettings>And add the<add ... />tags that are contained in the app.config file of the library project. You don’t need to change anything in your code for the ConfigurationManager class to figure this out. It knows where to look automagically.Hope that makes sense.