Retrieving WCF Configuration from C#

WcfConfigDetails details = new WcfConfigDetails();
            details.Populated = false;

            Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ServiceModelSectionGroup serviceModel = ServiceModelSectionGroup.GetSectionGroup(appConfig);
            BindingsSection bindings = serviceModel.Bindings;

            ChannelEndpointElement element = (from ChannelEndpointElement p in serviceModel.Client.Endpoints
                                              where p.Name == endPointName
                                              select p).FirstOrDefault();

            if (element == null) { return details; }

            details.Port = element.Address.Port;
            details.HostName = element.Address.Host.ToString();
            details.Populated = true;

            return details;

Comments

Popular posts from this blog

Enable Visual Studio to use more than 2GB of memory

Firefox and Chrome dark mode

Dealing with the morons who built Dell 7710 and RAID