2
votes

I have a .NET 3.5 WCF service hosted in IIS. The project service library has an app.config file with some configuration settings (Database connection strings, etc.). I deploy the project via a website project in Visual Studio, which generates a web.config to manage the endpoints. Is there a way I can put the app.config settings from my service library in to the web.config? The IIS hosted service seems to be using default values from the settings designer, and ignoring even an expliclty copied in app.config. I'm guessing this has something to do with the fact that a DLL can not utliize an app.config.

My service application is set up to pull the settings settings from the [MyAssembly].Properties.Settings.Default namespace.

1
when the WCF service is hosted in IIS, it's behaving like a web app and thus will be using a web.config - not its app.config .... Also: the .NET configuration system never uses the app.config for a class library - you need to put the settings into the hosting app's configuration.marc_s

1 Answers

1
votes

Can you use external configuration files?

Your web.config:

<config>
  ...
  <connectionStrings configSource="myConnections.config"></connectionStrings>
</config>

And then your external myConnections.config file:

<connectionStrings>
  <add ... />
</connectionStrings>

You can have multiple external configuration files referenced from your main web.config file. See see this blog post for a nice explanation of how/why to do this.

I hope this helps!