2009-06-13 13 views

Respuesta

9

Se puede cargar su archivo web.config utilizando WebConfigurationManager, obtener la sección <client>, y luego encontrar el elemento apropiado <endpoint> (por nombre o por dirección o lo que sea) y luego perforar en ella para encontrar el valor de DNS:

ClientSection clientSection = (WebConfigurationManager.GetSection("system.serviceModel/client") as ClientSection); 

foreach(ChannelEndpointElement cee in clientSection.Endpoints) 
{ 
    if(cee.Name == "ConfigurationManagerTcp") 
    { 
     IdentityElement ie = cee.Identity; 

     string dnsValue = ie.Dns.Value; 
    } 
} 

Tendrá que utilizar los espacios de nombres System.Web.Configuration y System.ServiceModel.COnfiguration para las clases implicadas.

Marc

Cuestiones relacionadas