0
Answer

Generate Xml of Services & Behavior from Configuration code

Photo of david miller

david miller

10y
894
1
  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?
 
 
 

Answers (0)