file=Path.GetFileName("some path")+".exe"; var configuration = ConfigurationManager.OpenExeConfiguration(file); var contractGenerator = new ServiceContractGenerator(configuration); string bindingSectionName; string configurationName; contractGenerator.GenerateBinding(Binding binding, out bindingSectionName, out configurationName); BindingsSection bindingsSection = BindingsSection.GetSection(contractGenerator.Configuration); contractGenerator.Configuration.Save(); var xml=bindingsSection.SectionInformation.GetRawXml();