0

Suppose I have a C# class library project with an app.config file and I reference it an ASP.NET project that has a web.config file. Suppose I have a key in my web.config AppSettings called SmtpServerHostname. If I need the SmtpServerHostname in my referenced class library as well, how should I handle configuring the configuration files? Specifically,

  1. If I don't define the SmtpServerHostname key in my class library, will that "pass through" because it is being referenced by another project where it is defined?
  2. If I do define the key in my class library, which one will take precedence?
  3. I currently make use of web.config transforms when publishing my application. Is it possible to transform the app.config file similarly?
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126

1 Answers1

0

It doesn't work that way. There is no merging. In the ASP.NET application, the app.config settings (or library.dll.config) will not be used in any way. You have to set the web.config yourself for the settings you want the ASP.NET application to see.

This is a duplicate, but I'll answer until I or someone else can properly close it as a duplicate.

John Saunders
  • 160,644
  • 26
  • 247
  • 397