Is there a way to write in a app.config file the information about endpoints?
Actually I want to read the <service> tag from one app.config file and want to write it in other app.config file’s <Services> tag.
Please anyone tell me how can I do it?
Actually I have a config file called “WCFService.exe.config” which i want to read in my program , so what i am writing is:
string path = Path.Combine(Application.StartupPath, "WCFService.exe.config");
Configuration config = ConfigurationManager.OpenExeConfiguration(path)
ServicesSection serviceSection = ConfigurationManager.GetSection("system.serviceModel/services") as ServicesSection;
ServiceElementCollection sereleColl = serviceSection.Services;
but i get nothing in sereleColl.
Take a look at the ConfigurationManager class
I don’t remember how to do it though.
Edit:
To access it you have to add a reference to System.Configuration.
Edit 2:
Changing the appsettings can be done like this:
You can access the WCF settings by typing:
Hope this helps.
Comment:
Your code is working fine here. However, I changed
to
This will use the config file of the application currently running. I don’t know why your path doesn’t work. Either it’s that, or there must be an error in your config file?