I found the correct answer myself.
I need to check the property ElementInformation.Source.
Given the following configuration:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding maxReceivedMessageSize="1000000"/>
</netTcpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
And the next application
using System;
using System.Configuration;
using System.ServiceModel.Configuration;
namespace ConsoleApplication49
{
class Program
{
static void Main(string[] args)
{
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var bingingsSection = BindingsSection.GetSection(config);
string netTcpSource = bingingsSection.NetTcpBinding.ElementInformation.Source;
string basicHttpSource = bingingsSection.BasicHttpBinding.ElementInformation.Source;
Console.WriteLine("Net TCP Binding came from \"{0}\"", netTcpSource);
Console.WriteLine("Basic HTTP Binding came from \"{0}\"", basicHttpSource);
}
}
}
Outputs:
Net TCP Binding came from "c:\users\Jim\documents\visual studio 2010\Projects\ConsoleApplication49\ConsoleApplication49\bin\Debug\ConsoleApplication49.exe.Config"
Basic HTTP Binding came from ""
Press any key to continue . . .
, , app.config, , , , app.config, . , .