[RESOLVED] WCF 4.0 - Config Settings
Hi ALL,
I wrote a standard web app, but because a portion of it is long running I need to turn it into a WCF Service. I'm creating a WCF Service Library as opposed to an Application.
In my original Web app one of my classes obtained connection string details to the database from the connectionstrings settings of the Web.config file with a reference to the 'Using System.Configuration' such that my call was:
Code:
private static string DB_CONNECTION_STRING = ConfigurationManager.ConnectionStrings["Database"].ToString();
I notice that in my WCF Service, I have App.Config. Can anyone tell me how I should set this in the App.Config file and how I should reference it
Re: WCF 4.0 - Config Settings
Yes. You need to set the connection strings in your connection string section of the app.config.
Code:
<connectionstring>
<add name="Database" connectionString="YourConnectionString"/>
</connectionstring>
Re: WCF 4.0 - Config Settings
You'll need access to the System.Configuration dll to reference this. In an initialization routine, get your system.configurationmanager to read all the values from your config file and assing them to static string variables.