views:

1571

answers:

1

Hello everyone,

I am using VSTS 2008 + C# + .Net 3.0. I am using self-hosted WCF. When executing the following statement, there is the following binding not found error. I have posted my whole app.config file, any ideas what is wrong?

ServiceHost host = new ServiceHost(typeof(MyWCFService));

Error message,

Configuration binding extension 'system.serviceModel/bindings/MyBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

Full app.config,

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="MyBinding"
            closeTimeout="00:00:10"
            openTimeout="00:00:20"
            receiveTimeout="00:00:30"
            sendTimeout="00:00:40"
            bypassProxyOnLocal="false"
            transactionFlow="false"
            hostNameComparisonMode="WeakWildcard"
            maxReceivedMessageSize="100000000"
            messageEncoding="Mtom"
            proxyAddress="http://foo/bar"
            textEncoding="utf-16"
            useDefaultWebProxy="false">
          <reliableSession ordered="false"
               inactivityTimeout="00:02:00"
               enabled="true" />
          <security mode="Transport">
            <transport clientCredentialType="Digest"
               proxyCredentialType="None"
               realm="someRealm" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="MyWCFService"
                behaviorConfiguration="mexServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:9090/MyService"/&gt;
          </baseAddresses>
        </host>
        <endpoint address="" binding="MyBinding" contract="IMyService"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

thanks in advance, George

+4  A: 

You've misunderstood how to configure bindings - your binding in the endpoint needs to be a known protocol;

 <endpoint address="" binding="wsHttpBinding" contract="IMyService"/>

Once you have that you can then specify the binding configuration you have defined within the settings for that protocol using the bindingConfiguration element thus

 <endpoint address="" binding="wsHttpBinding" 
  bindingConfiguration="MyBinding" contract="IMyService"/>
blowdart
+1 Yup, that's the cause - the way George2 is using the "MyBinding" is as if there was a complete BINDING (not just a binding configuration) by that name.
marc_s
Cool! Solved! But I met with a new issue when apply your comments and the new issue is about mex binding issue. I have posted here, an ideas what is wrong?http://stackoverflow.com/questions/1026149/mex-binding-error-in-wcf
George2
Thanks marc_s! //blush My fault to fully understand the technology. I have posted a related issue about mex (as a new issue, I start a new thread to be clear) here, appreciate if you could take a look,http://stackoverflow.com/questions/1026149/mex-binding-error-in-wcf
George2
Thanks - saved my day.
Martin