|
-
Mar 28th, 2011, 08:58 AM
#1
Thread Starter
Fanatic Member
[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
Last edited by Bill Crawley; Mar 28th, 2011 at 09:46 AM.
-
Mar 28th, 2011, 03:02 PM
#2
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>
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Mar 28th, 2011, 03:03 PM
#3
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.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|