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.
Right-click on the solution in Solution Explorer and select Add > New Project. On the Add a new project page, enter library in the search box. Choose C# or Visual Basic from the Language list, and then choose All platforms from the Platform list. Choose the Class Library template, and then choose Next.
To add a reference to the class library project In Solution Explorer, right-click the References node underneath CDemoTest, and then click Add Reference. In the Add Reference dialog box, select the Projects tab.
DLL in the C# Programming Language. The Class Library . DLL contains program code, data, and resources that can be can used by other programs and are easily implemented into other Visual Studio projects.
Use a . NET Core library when you want to increase the . NET API surface area your library can access, and you are okay with allowing only . NET Core applications to be compatible with your library.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With