MoazzamAhmed

hi all,

I need to read ALL <client><endpoint> sections from my web.config file.

I dont know how many there are.

Is there a way I can read the whole <client> section using WebConfigurationManager.GetSection,

and then iterate over the endpoints

thanks,

Moazzam




Re: Windows Communication Foundation (Indigo) Reading client section programattically

Dave Cliffe - MSFT

Hi Moazzam,

You'll want to use the ServiceModelSectionGroup for this, actually. See the following snippet:

Code Snippet

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

ServiceModelSectionGroup sectionGroup = ServiceModelSectionGroup.GetSectionGroup(config);

foreach (ChannelEndpointElement channelEndpointElement in sectionGroup.Client.Endpoints)

{

channelEndpointElement.Address = new Uri(channelEndpointElement.Address.ToString() + "A");

}

config.Save();

ConfigurationManager.RefreshSection("system.serviceModel/client");

Hope this is what you're looking for,

-- Dave





Re: Windows Communication Foundation (Indigo) Reading client section programattically

Ariunaa Mongolia

How to fix this error. Help me please.
Dim Config As Configuration
Dim Section As ConnectionStringsSection
Dim Setting As ConnectionStringSettings
Dim ConnectionFullName As String

Try
'Concatenate the full settings name
ConnectionFullName = Session("NewGeneratedConnectionString")

'Point out the objects to manipulate
Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Section = CType(Config.GetSection("connectionStrings"), ConnectionStringsSection)
Setting = Section.ConnectionStrings(ConnectionFullName)

Error has occurred when bolded code running.Error message that Exe path must be specified when not running inside a stand alone exe

<!--[if !vml]--> <![endif]--><!--[if !vml]--><!--[endif]-->