System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(typeof(ConfigOperation).Assembly.Location);
System.ServiceModel.Configuration.ServiceModelSectionGroup serviceModelSection = System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup(configuration);
//setting clientCertificateName
var enumer = serviceModelSection.Behaviors.EndpointBehaviors.GetEnumerator(); enumer.MoveNext();
System.ServiceModel.Configuration.EndpointBehaviorElement endpointBehaviour = (System.ServiceModel.Configuration.EndpointBehaviorElement)enumer.Current;
System.ServiceModel.Configuration.ClientCredentialsElement clientCred = (System.ServiceModel.Configuration.ClientCredentialsElement)endpointBehaviour.First();
clientCred.ClientCertificate.FindValue = "CERTIFICATE_NAME”;
//save config file
configuration.Save(System.Configuration.ConfigurationSaveMode.Modified, true);
where's your assemblies' "using" references?
ReplyDelete