ServiceModelSectionGroup serviceModel = ServiceModelSectionGroup.GetSectionGroup(开发者_如何学JAVAappConfig);
Given the above is there anyway possible to get a ServiceModelSectionGroup from a string/xml in memory and NOT from a configuration object or file?
Depending on whether or not you can create a temporary file, this article offers a potential solution:
http://blogs.u2u.be/diederik/post/2010/07/29/Get-your-WCF-client-configuration-from-anywhere.aspx
"I'll build a custom channel factory -derived from ChannelFactory- that reads its WCF client configuration from a custom configuration file. Then I plug this channel factory into the proxy that was generated by Visual Studio.NET."
And...
"Some of the non-virtual members and constructors of the classes in the ChannelFactory hierarchy use the System.Configuration namespace to parse the address, binding, and contract information. The classes in this namespace are specialized in reading configuration sections from physical XML configuration files à la app.config. These classes require a file path to do their work. So there's no way around a config file - at least a temporary one."
精彩评论