Aslam Jiffry
Aslam Jiffry

Reputation: 1316

Accessing a app.config file property in another app.config file

I have a WCF class library which implements a Windows Service business logic.In app.config file i defined a property called "debug mode" for debugging purposes.

Then i have created separate Windows Service and where i used above created WCF class library as a reference(by adding .dll file and "using name" statement).

I need to set "debug mode" property in wcf class library app.config file using Windows service app.config files.

is it possible ? or do i have any alternate method.

Upvotes: 0

Views: 219

Answers (2)

evgenyl
evgenyl

Reputation: 8107

If you are using appSettings and ConfigurationManager to read your property, you have to put (copy - as @JohnSounders explaine) your property into your windows service config file.

In other case - you'll not be able to retrieve it from config.

In usual way, your application will look for configuration of current running executable (in your case - windows service).

Upvotes: 1

Brian Ogden
Brian Ogden

Reputation: 19212

You should be able to have one app.config and both the WCF library and the windows service can read from it. The windows service is the current thread and references the WCF library so the WCF library has access to the windows service's app.config.

Upvotes: 0

Related Questions