david miller

david miller

  • NA
  • 1
  • 794

Generate Xml of Services & Behavior from Configuration code

Jul 8 2015 10:26 AM
  In my wcf application ,configured service through code not by app.config.I can generate binding section xml by below code
 
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();
 
But cannot Generate XML of Services or Behavior as ServiceContractGenerator dont have any method like GenerateServices() or GenerateBehavior().Is their any other way to create xml of these section of app.config?