WCF - Reading from Application Configuration File - config section - system.serviceModel

I can't find any example on the web for this, so i guess it could be helpful.
This is a simple example to show a way to read the system.serviceModel configuration section in application/web configuration file.

Something like for
ConnectionString, there is a straightforward class for that,
ConfigurationManager.ConnectionStrings["keyname"].ConnectionString

Codes snippet below

ServiceModelSectionGroup group = ServiceModelSectionGroup.GetSectionGroup(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None));

//suppose if there is only one endpoint
if(group.Client.Endpoints.Count < 0)
{
uri = group.Client.Endpoints[0].Address.AbsoluteUri;
}

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file

MSSQL GROUP_CONCAT