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;
}
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